mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=4175
This commit is contained in:
parent
219f8c3a2f
commit
46385bdae7
|
@ -17216,3 +17216,10 @@ David 9 Sept 2004
|
|||
sample_trivial_validator.C
|
||||
validate_util.C,h
|
||||
validator.C
|
||||
|
||||
David 9 Sept 2004
|
||||
- added try_fopen() (from Jeff Cobb):
|
||||
like fopen(), but on tells you whether it's recoverable or not
|
||||
|
||||
lib/
|
||||
util.C,h
|
||||
|
|
31
lib/util.C
31
lib/util.C
|
@ -765,3 +765,34 @@ int dir_hier_url(
|
|||
sprintf(result, "%s/%x/%s", root, sum, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// try to open a file.
|
||||
// On failure:
|
||||
// return ERR_FOPEN if the dir is there but not file
|
||||
// (this is generally a nonrecoverable failure)
|
||||
// return ERR_OPENDIR if dir is not there.
|
||||
// (this is generally a recoverable error,
|
||||
// like NFS mount failure, that may go away later)
|
||||
//
|
||||
int try_fopen(char* path, FILE*& f, char* mode) {
|
||||
char* p;
|
||||
DIR* d;
|
||||
char dirpath[256];
|
||||
|
||||
f = fopen(path, mode);
|
||||
if (!f) {
|
||||
p = strrchr(path, '/');
|
||||
if (p) {
|
||||
strncpy(dirpath, path, (int)(p-path));
|
||||
} else {
|
||||
strcpy(dirpath, ".");
|
||||
}
|
||||
if ((d = opendir(dirpath)) == NULL) {
|
||||
return ERR_OPENDIR;
|
||||
} else {
|
||||
closedir(d);
|
||||
return ERR_FOPEN;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -127,4 +127,6 @@ extern int dir_hier_url(
|
|||
const char* filename, const char* root, int fanout, char* result
|
||||
);
|
||||
|
||||
extern int try_fopen(char* path, FILE*& f, char* mode);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
// assimilator [ -noinsert ]
|
||||
// This is a framework for an assimilator.
|
||||
// You need to link with with an (application-specific) function
|
||||
// assimilate_handler()
|
||||
// in order to make a complete program.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
|
|
Loading…
Reference in New Issue