Thread: anyone know a function to get the group name of a file?

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    5

    anyone know a function to get the group name of a file?

    I have the Group ID in stored in a gid_t variable.

    Thanks.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    5
    anyone??

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Explain!!!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I suspect this is an OS specific issue. You have folders/files assigned to a user group and want to find out what group they're in?

    Otherwise:

    > I have the Group ID in stored in a gid_t variable.

    Otherwise, if you have the group id stored in a variable, just access the variable. Surely you can do that much!

    Seriously, I think they're talking about an OS specific quesiton here.

    Quzah.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    5
    OK, let me try and explain it a little better....

    I have a program that traverses the file system and gets information on certain programs. I then use the getpwuid function to pull information about the file. I can get all the information I need except the group name of the owner of the file.
    I can get the group ID, but not the name. What I need is to take the group ID and get the corresponding group name. I can't just check the /etc/group file, I was wondering if there was a function that does that.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Like I said before: This is an OS specific question. What OS are you using?

    Quzah.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    5
    Ideally, this should work under Linux and HPUX.

  8. #8
    Unregistered
    Guest
    Code:
    struct stat {
              mode_t   st_mode;     /* File mode (type, perms) */
              ino_t    st_ino;      /* Inode number */
              dev_t    st_dev;      /* ID of device containing */
                                    /* a directory entry for this file */
              dev_t    st_rdev;     /* ID of device */
                                    /* This entry is defined only for */
                                    /* char special or block special files */
              nlink_t  st_nlink;    /* Number of links */
              uid_t    st_uid;      /* User ID of the file's owner */
              gid_t    st_gid;      /* Group ID of the file's group */
              off_t    st_size;     /* File size in bytes */
              time_t   st_atime;    /* Time of last access */
              time_t   st_mtime;    /* Time of last data modification */
              time_t   st_ctime;    /* Time of last file status change */
                                    /* Times measured in seconds since */
                                    /* 00:00:00 UTC, Jan. 1, 1970 */
              long     st_blksize;  /* Preferred I/O block size */
              blkcnt_t st_blocks;   /* Number of 512 byte blocks allocated*/
    }
    http://www.cm.cf.ac.uk/Dave/C/node20...00000000000000

    You really should try your hand at using a search engine...

    http://www.rt.com/man/getgroups.2.html /* useful */
    http://www.rt.com/man/ /* the main index. bookmark it. */
    http://www.rt.com/man/group.5.html /* surely it can't be that eas? can it? */
    http://www.rt.com/man/groups.1.html
    http://www.rt.com/man/setgroups.2.html


    Quzah.

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    God damn this stupid timer. I hate this message board's login timer. How hard is it to simply notice that "hey, the window has the user signed in, perhaps they're still signed in, eh?" They need PER SESSION cookies. Not 2 second expiration.

    Quzah.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM