g_chmod to g_chmod_hex

This commit is contained in:
jsorg71 2006-10-28 03:28:59 +00:00
parent fe292cec20
commit cf00c1707d
3 changed files with 19 additions and 4 deletions

View File

@ -651,12 +651,27 @@ g_set_file_rights(char* filename, int read, int write)
/*****************************************************************************/
/* returns error */
int
g_chmod(char* filename, int flags)
g_chmod_hex(char* filename, int flags)
{
#if defined(_WIN32)
return 0;
#else
return chmod(filename, flags);
int fl;
fl = 0;
fl |= (flags & 0x4000) ? S_ISUID : 0;
fl |= (flags & 0x2000) ? S_ISGID : 0;
fl |= (flags & 0x1000) ? S_ISVTX : 0;
fl |= (flags & 0x0400) ? S_IRUSR : 0;
fl |= (flags & 0x0200) ? S_IWUSR : 0;
fl |= (flags & 0x0100) ? S_IXUSR : 0;
fl |= (flags & 0x0040) ? S_IRGRP : 0;
fl |= (flags & 0x0020) ? S_IWGRP : 0;
fl |= (flags & 0x0010) ? S_IXGRP : 0;
fl |= (flags & 0x0004) ? S_IROTH : 0;
fl |= (flags & 0x0002) ? S_IWOTH : 0;
fl |= (flags & 0x0001) ? S_IXOTH : 0;
return chmod(filename, fl);
#endif
}

View File

@ -100,7 +100,7 @@ g_file_lock(int fd, int start, int len);
int
g_set_file_rights(char* filename, int read, int write);
int
g_chmod(char* filename, int flags);
g_chmod_hex(char* filename, int flags);
int
g_mkdir(char* dirname);
char*

View File

@ -267,7 +267,7 @@ main(int argc, char** argv)
if (!g_directory_exist("/tmp/.X11-unix"))
{
g_create_dir("/tmp/.X11-unix");
g_chmod("/tmp/.X11-unix", 0x1777);
g_chmod_hex("/tmp/.X11-unix", 0x1777);
}
sesman_main_loop();