Hi!
Ich habe da mal was gemacht in C++:
Code:
#include <iostream>
#include <string>
#include <sys/stat.h>
std::string convert(mode_t mode)
{
std::string str;
if(mode & S_IFDIR)
str += 'd';
else
str += '-';
if(mode & S_IRUSR)
str += 'r';
else
str += '-';
if(mode & S_IWUSR)
str += 'w';
else
str += '-';
if(mode & S_IXUSR)
str += 'x';
else
str += '-';
if(mode & S_IRGRP)
str += 'r';
else
str += '-';
if(mode & S_IWGRP)
str += 'w';
else
str += '-';
if(mode & S_IXGRP)
str += 'x';
else
str += '-';
if(mode & S_IROTH)
str += 'r';
else
str += '-';
if(mode & S_IWOTH)
str += 'w';
else
str += '-';
if(mode & S_IXOTH)
str += 'x';
else
str += '-';
return str;
}
int main(int argc, char **argv)
{
struct stat buf;
stat("test", &buf);
std::cout << convert(buf.st_mode) << std::endl;
return 0;
}
Informationen zu den S_I****-Sachen stehen in der man-Page zu stat (man 2 stat)
Hoffe das hilft dir
c ya,
Tobias
Lesezeichen