20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <errno.h>
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
#include "unistd_wrapper.h"
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#include <sys/time.h>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#endif
|
>
>
>
>
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <errno.h>
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
#include "unistd_wrapper.h"
#import "platform.h"
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#include <sys/time.h>
#ifdef OF_WINDOWS
# include <utime.h>
#endif
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#endif
|
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
- (void)of_setModificationDate: (OFDate *)date
ofItemAtURL: (OFURL *)URL
attributes: (of_file_attributes_t)attributes
{
of_time_interval_t timeInterval = date.timeIntervalSince1970;
OFString *path = URL.fileSystemRepresentation;
struct timeval times[2] = {
{
.tv_sec = (time_t)timeInterval,
.tv_usec =
(int)((timeInterval - times[0].tv_sec) * 1000)
},
times[0]
};
if (utimes([path cStringWithEncoding: [OFLocale encoding]], times) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
attributes: attributes
failedAttribute: of_file_attribute_key_modification_date
errNo: errno];
}
- (void)of_setPOSIXPermissions: (OFNumber *)permissions
ofItemAtURL: (OFURL *)URL
attributes: (of_file_attributes_t)attributes
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
- (void)of_setModificationDate: (OFDate *)date
ofItemAtURL: (OFURL *)URL
attributes: (of_file_attributes_t)attributes
{
of_time_interval_t timeInterval = date.timeIntervalSince1970;
OFString *path = URL.fileSystemRepresentation;
#ifdef OF_WINDOWS
struct __utimbuf64 times = {
(__time64_t)timeInterval,
(__time64_t)timeInterval
};
if (_wutime64([path UTF16String], ×) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
attributes: attributes
failedAttribute: of_file_attribute_key_modification_date
errNo: errno];
#else
struct timeval times[2] = {
{
.tv_sec = (time_t)timeInterval,
.tv_usec =
(int)((timeInterval - times[0].tv_sec) * 1000)
},
times[0]
};
if (utimes([path cStringWithEncoding: [OFLocale encoding]], times) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
attributes: attributes
failedAttribute: of_file_attribute_key_modification_date
errNo: errno];
#endif
}
- (void)of_setPOSIXPermissions: (OFNumber *)permissions
ofItemAtURL: (OFURL *)URL
attributes: (of_file_attributes_t)attributes
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
|