753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
|
exceptionWithPath: path
permissions: permissions
errNo: errno];
}
#endif
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
- (void)getOwner: (OFString **)owner
group: (OFString **)group
ofItemAtPath: (OFString *)path
{
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) != 0)
@throw [OFStatItemFailedException exceptionWithPath: path
errNo: errno];
# ifdef OF_HAVE_THREADS
[passwdMutex lock];
@try {
# endif
of_string_encoding_t encoding = [OFLocalization encoding];
if (owner != NULL) {
struct passwd *passwd = getpwuid(s.st_uid);
*owner = [OFString stringWithCString: passwd->pw_name
encoding: encoding];
}
if (group != NULL) {
struct group *group_ = getgrgid(s.st_gid);
*group = [OFString stringWithCString: group_->gr_name
encoding: encoding];
}
# ifdef OF_HAVE_THREADS
} @finally {
[passwdMutex unlock];
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
|
exceptionWithPath: path
permissions: permissions
errNo: errno];
}
#endif
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
- (void)getUID: (uint16_t *)UID
GID: (uint16_t *)GID
ofItemAtPath: (OFString *)path
{
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) != 0)
@throw [OFStatItemFailedException exceptionWithPath: path
errNo: errno];
if (UID != NULL)
*UID = s.st_uid;
if (GID != NULL)
*GID = s.st_gid;
}
- (void)getOwner: (OFString **)owner
group: (OFString **)group
ofItemAtPath: (OFString *)path
{
uint16_t UID, GID;
[self getUID: &UID
GID: &GID
ofItemAtPath: path];
# ifdef OF_HAVE_THREADS
[passwdMutex lock];
@try {
# endif
of_string_encoding_t encoding = [OFLocalization encoding];
if (owner != NULL) {
struct passwd *passwd = getpwuid(UID);
*owner = [OFString stringWithCString: passwd->pw_name
encoding: encoding];
}
if (group != NULL) {
struct group *group_ = getgrgid(GID);
*group = [OFString stringWithCString: group_->gr_name
encoding: encoding];
}
# ifdef OF_HAVE_THREADS
} @finally {
[passwdMutex unlock];
|