00001
00002
00003
00004 #include <sys/stat.h>
00005 #include <errno.h>
00006 #include "debug.h"
00007 #include "utils.h"
00008 #include "datetime.h"
00009 #include "filesystem.h"
00010
00011 char *getRuleBasePath(char *ruleBaseName, char rulesFileName[MAX_NAME_LEN]) {
00012 char *configDir = getConfigDir ();
00013 snprintf (rulesFileName, MAX_NAME_LEN, "%s/reConfigs/%s.re", configDir,ruleBaseName);
00014 return rulesFileName;
00015
00016 }
00017 void getResourceName(char buf[1024], char *rname) {
00018 snprintf(buf, 1024, "%s/%s", getConfigDir(), rname);
00019 char *ch = buf;
00020 while(*ch != '\0') {
00021 if(*ch == '\\' || *ch == '/') {
00022 *ch = '_';
00023 }
00024 ch++;
00025 }
00026
00027 }
00028
00029 int getModifiedTime(char *fn, time_type *timestamp) {
00030 #ifdef USE_BOOST
00031 boost::filesystem::path path(fn);
00032 time_type time = boost::filesystem::last_write_time(path);
00033 time_type_set(*timestamp, time);
00034 return 0;
00035 #else
00036
00037 struct stat filestat;
00038
00039 if(stat(fn, &filestat) == -1) {
00040 rodsLog(LOG_ERROR, "error reading file stat %s\n", fn);
00041 return RE_FILE_STAT_ERROR - errno;
00042 }
00043 time_type_set(*timestamp, filestat.st_mtime);
00044 return 0;
00045 #endif
00046 }