added g_create_dir, g_directory_exist, g_remove_dir, and g_chmod
This commit is contained in:
parent
5dfa4e3f39
commit
bd252214a3
@ -648,6 +648,18 @@ g_set_file_rights(char* filename, int read, int write)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* returns error */
|
||||||
|
int
|
||||||
|
g_chmod(char* filename, int flags)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return chmod(filename, flags);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* returns error, always zero */
|
/* returns error, always zero */
|
||||||
int
|
int
|
||||||
@ -702,12 +714,58 @@ int
|
|||||||
g_file_exist(char* filename)
|
g_file_exist(char* filename)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return 0; // use FindFirstFile();
|
return 0; // use FileAge(filename) <> -1
|
||||||
#else
|
#else
|
||||||
return access(filename, F_OK) == 0;
|
return access(filename, F_OK) == 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* returns boolean, non zero if the directory exists */
|
||||||
|
int
|
||||||
|
g_directory_exist(char* dirname)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return 0; // use GetFileAttributes and check return value
|
||||||
|
// is not -1 and FILE_ATTRIBUT_DIRECTORY bit is set
|
||||||
|
#else
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (stat(dirname, &st) == 0)
|
||||||
|
{
|
||||||
|
return S_ISDIR(st.st_mode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* returns boolean */
|
||||||
|
int
|
||||||
|
g_create_dir(char* dirname)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return CreateDirectory(dirname, 0); // test this
|
||||||
|
#else
|
||||||
|
return mkdir(dirname, (mode_t)-1) == 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* returns boolean */
|
||||||
|
int
|
||||||
|
g_remove_dir(char* dirname)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return RemoveDirectory(dirname); // test this
|
||||||
|
#else
|
||||||
|
return rmdir(dirname) == 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* returns non zero if the file was deleted */
|
/* returns non zero if the file was deleted */
|
||||||
int
|
int
|
||||||
|
@ -100,6 +100,8 @@ g_file_lock(int fd, int start, int len);
|
|||||||
int
|
int
|
||||||
g_set_file_rights(char* filename, int read, int write);
|
g_set_file_rights(char* filename, int read, int write);
|
||||||
int
|
int
|
||||||
|
g_chmod(char* filename, int flags);
|
||||||
|
int
|
||||||
g_mkdir(char* dirname);
|
g_mkdir(char* dirname);
|
||||||
char*
|
char*
|
||||||
g_get_current_dir(char* dirname, int maxlen);
|
g_get_current_dir(char* dirname, int maxlen);
|
||||||
@ -108,6 +110,12 @@ g_set_current_dir(char* dirname);
|
|||||||
int
|
int
|
||||||
g_file_exist(char* filename);
|
g_file_exist(char* filename);
|
||||||
int
|
int
|
||||||
|
g_directory_exist(char* dirname);
|
||||||
|
int
|
||||||
|
g_create_dir(char* dirname);
|
||||||
|
int
|
||||||
|
g_remove_dir(char* dirname);
|
||||||
|
int
|
||||||
g_file_delete(char* filename);
|
g_file_delete(char* filename);
|
||||||
int
|
int
|
||||||
g_strlen(char* text);
|
g_strlen(char* text);
|
||||||
|
Loading…
Reference in New Issue
Block a user