|
@@ -142,13 +142,28 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
-int check_filepath(const char* filepath){
|
|
|
|
|
|
+/**
|
|
|
|
+ * Check if the path is a directory or file
|
|
|
|
+ * @param filepath: Location of file
|
|
|
|
+ * @return 0 = Error
|
|
|
|
+ * 1 = Directory
|
|
|
|
+ * 2 = File
|
|
|
|
+ * 3 = File but doesn't exist
|
|
|
|
+ */
|
|
|
|
+int check_filepath(const char* filepath)
|
|
|
|
+{
|
|
DWORD Attribute;
|
|
DWORD Attribute;
|
|
- if( Attribute = GetFileAttributes(filepath) ){
|
|
|
|
- if( (Attribute & INVALID_FILE_ATTRIBUTES) && GetLastError() == ERROR_FILE_NOT_FOUND ) return 3;
|
|
|
|
- else if( Attribute & FILE_ATTRIBUTE_DIRECTORY ) return 1;
|
|
|
|
- else return 2;
|
|
|
|
|
|
+
|
|
|
|
+ if (Attribute = GetFileAttributes(filepath)) {
|
|
|
|
+ if ((Attribute&INVALID_FILE_ATTRIBUTES) && GetLastError() == ERROR_FILE_NOT_FOUND) {
|
|
|
|
+ SetLastError(0);
|
|
|
|
+ return 3;
|
|
|
|
+ } else if (Attribute&FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
+ return 1;
|
|
|
|
+ else
|
|
|
|
+ return 2;
|
|
}
|
|
}
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -156,23 +171,28 @@ int check_filepath(const char* filepath){
|
|
|
|
|
|
#define MAX_DIR_PATH 2048
|
|
#define MAX_DIR_PATH 2048
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Check if the path is a directory or file
|
|
* Check if the path is a directory or file
|
|
- * @param filepath
|
|
|
|
- * @return 1=dir, 2=file, 3=else, 0=error
|
|
|
|
|
|
+ * @param filepath: Location of file
|
|
|
|
+ * @return 0 = Error
|
|
|
|
+ * 1 = Directory
|
|
|
|
+ * 2 = File
|
|
|
|
+ * 3 = Neither a file or directory
|
|
*/
|
|
*/
|
|
-int check_filepath(const char* filepath){
|
|
|
|
- struct stat s;
|
|
|
|
-
|
|
|
|
- if( stat(filepath,&s) == 0 ){
|
|
|
|
- if( s.st_mode & S_IFDIR ) return 1;
|
|
|
|
- else if( s.st_mode & S_IFREG )return 2;
|
|
|
|
- else return 3;
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
|
|
+int check_filepath(const char* filepath)
|
|
|
|
+{
|
|
|
|
+ struct stat s;
|
|
|
|
+
|
|
|
|
+ if (stat(filepath, &s) == 0) {
|
|
|
|
+ if (s.st_mode&S_IFDIR)
|
|
|
|
+ return 1;
|
|
|
|
+ else if (s.st_mode&S_IFREG)
|
|
|
|
+ return 2;
|
|
|
|
+ else
|
|
|
|
+ return 3;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
static char* checkpath(char *path, const char*srcpath)
|
|
static char* checkpath(char *path, const char*srcpath)
|