- Library: switch from lstat() back to stat() most places;

this broke some projects' back-end code.
    Make a new function (boinc_file_or_symlink_exists())
    for use by the client when clearing out slot dirs

svn path=/trunk/boinc/; revision=14968
This commit is contained in:
David Anderson 2008-03-27 20:30:19 +00:00
parent a55712dde0
commit 2080d9dcc0
4 changed files with 30 additions and 8 deletions

View File

@ -2705,3 +2705,14 @@ David Mar 27 2008
tools/
update_versions
version.h
David Mar 27 2008
- Library: switch from lstat() back to stat() most places;
this broke some projects' back-end code.
Make a new function (boinc_file_or_symlink_exists())
for use by the client when clearing out slot dirs
client/
sandbox.C
lib/
filesys.C,h

View File

@ -149,12 +149,12 @@ static int delete_project_owned_file_aux(const char* path) {
// Delete the file located at path.
// If "retry" is set, do retries for 5 sec in case some
// other program (e.g. virus checker) has the file locked.
// Don't do this if deleting directories - it can lock up Manager.
// Don't do this if deleting directories - it can lock up the Manager.
//
int delete_project_owned_file(const char* path, bool retry) {
int retval = 0;
if (!boinc_file_exists(path)) {
if (!boinc_file_or_symlink_exists(path)) {
return 0;
}
retval = delete_project_owned_file_aux(path);

View File

@ -74,20 +74,17 @@ using std::string;
char boinc_failed_file[256];
#ifdef _WIN32
#define lstat(x,y) stat(x,y)
#endif
// routines for enumerating the entries in a directory
int is_file(const char* path) {
struct stat sbuf;
int retval = lstat(path, &sbuf);
int retval = stat(path, &sbuf);
return (!retval && (sbuf.st_mode & S_IFREG));
}
int is_dir(const char* path) {
struct stat sbuf;
int retval = lstat(path, &sbuf);
int retval = stat(path, &sbuf);
return (!retval && (sbuf.st_mode & S_IFDIR));
}
@ -287,7 +284,7 @@ int file_size(const char* path, double& size) {
struct stat sbuf;
int retval;
retval = lstat(path, &sbuf);
retval = stat(path, &sbuf);
if (retval) return ERR_NOT_FOUND;
size = (double)sbuf.st_size;
return 0;
@ -445,8 +442,21 @@ FILE* boinc_fopen(const char* path, const char* mode) {
int boinc_file_exists(const char* path) {
struct stat buf;
if (stat(path, &buf)) {
return false; // stat() returns zero on success
}
return true;
}
// same, but doesn't traverse symlinks
//
int boinc_file_or_symlink_exists(const char* path) {
struct stat buf;
#ifdef _WIN32
if (stat(path, &buf)) {
#else
if (lstat(path, &buf)) {
#endif
return false; // stat() returns zero on success
}
return true;

View File

@ -59,6 +59,7 @@ extern "C" {
extern int is_dir(const char* path);
extern int boinc_truncate(const char*, double);
extern int boinc_file_exists(const char* path);
extern int boinc_file_or_symlink_exists(const char* path);
#ifdef __cplusplus
}