Changeset 9750 for trunk/psLib/src/types
- Timestamp:
- Oct 25, 2006, 6:44:09 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/types/psMetadataConfig.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psMetadataConfig.c
r9736 r9750 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.9 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-10-2 5 00:16:33$12 * @version $Revision: 1.98 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-26 04:44:09 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1166 1166 // Attempt to open specified file 1167 1167 int fd = 0; 1168 if (!(fd = open(filename, O_RDONLY))) { 1168 fd = open(filename, O_RDONLY); 1169 struct stat buf; // Results of stat() for file 1170 if (fd < 0 || fstat(fd, &buf) != 0) { 1169 1171 // XXX really should return strerror() here 1170 1172 psError(PS_ERR_IO, true, 1171 1173 _("Failed to open file '%s'. Check if it exists and it has the proper " 1172 1174 "permissions."), filename); 1175 close(fd); 1173 1176 return NULL; 1174 1177 } 1175 1176 struct stat buf; // Results of stat() for file 1178 /* This appears to be unreachable, but moving to check above just to be sure. 1177 1179 if (fstat(fd, &buf) != 0) { 1178 1180 psError(PS_ERR_IO, true, _("Unable to stat file '%s'.\n"), filename); … … 1180 1182 return NULL; 1181 1183 } 1182 1184 */ 1183 1185 // psMetadataConfigParse() is going to read the entire file into memory so 1184 1186 // we're trying to be nice by allowing the VM to flush the file out of … … 1188 1190 if (file == MAP_FAILED) { 1189 1191 psError(PS_ERR_IO, true, _("failed to mmap() file %s"), filename); 1190 if (close(fd) != 0) { 1191 // XXX really should return strerror() here 1192 psError(PS_ERR_IO, true, _("Failed to close file '%s'."), filename); 1193 return NULL; 1194 } 1192 /* if (close(fd) != 0) { 1193 // XXX really should return strerror() here 1194 psError(PS_ERR_IO, true, _("Failed to close file '%s'."), filename); 1195 return NULL; 1196 } 1197 */ 1198 close(fd); 1195 1199 return NULL; 1196 1200 } … … 1199 1203 1200 1204 munmap(file, (size_t)buf.st_size); 1201 1205 /* 1202 1206 if (close(fd) != 0) { 1203 1207 // XXX really should return strerror() here … … 1205 1209 return NULL; 1206 1210 } 1207 1211 */ 1212 close(fd); 1208 1213 return md; 1209 1214 } … … 1241 1246 1242 1247 psList *doc = psStringSplit(str, "\n", false); 1243 if (!doc) { 1248 if (!doc || doc->n == 0) { 1249 if (doc != NULL) 1250 psFree(doc); 1244 1251 psFree(parseLevelInfoArray); 1245 1252 psFree(md);
Note:
See TracChangeset
for help on using the changeset viewer.
