mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-26 10:49:21 +00:00
Correctly set last-modified time on exported files in Windows.
This commit is contained in:
parent
e1693eb92b
commit
d776afa35a
@ -269,6 +269,14 @@ void get_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir)
|
|||||||
|
|
||||||
void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir)
|
void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir)
|
||||||
{
|
{
|
||||||
|
struct my_utimbuf times;
|
||||||
|
times.actime = MacTimeToTime(ReadMacInt32(finfo - ioFlFndrInfo + ioFlCrDat));
|
||||||
|
times.modtime = MacTimeToTime(ReadMacInt32(finfo - ioFlFndrInfo + ioFlMdDat));
|
||||||
|
|
||||||
|
if (utime(path, ×) < 0) {
|
||||||
|
D(bug("utime failed on %s, error %d\n", path, GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
// Open Finder info file
|
// Open Finder info file
|
||||||
int fd = open_finf(path, O_RDWR);
|
int fd = open_finf(path, O_RDWR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -1123,3 +1123,28 @@ int my_write( int fd, const void *buffer, unsigned int count )
|
|||||||
D(bug("write(%ld,%08x,%ld) = %d\n", fd, buffer, count, result));
|
D(bug("write(%ld,%08x,%ld) = %d\n", fd, buffer, count, result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILETIME getFileTime(time_t time) {
|
||||||
|
FILETIME ft;
|
||||||
|
unsigned long long result = 11644473600LL;
|
||||||
|
result += time;
|
||||||
|
result *= 10000000LL;
|
||||||
|
ft.dwHighDateTime = (result >> 32);
|
||||||
|
ft.dwLowDateTime = (result & 0xFFFFFFFF);
|
||||||
|
return ft;
|
||||||
|
}
|
||||||
|
|
||||||
|
int my_utime( const char *path, struct my_utimbuf * my_times )
|
||||||
|
{
|
||||||
|
auto tpath = tstr(path);
|
||||||
|
LPCTSTR p = MRP(tpath.get());
|
||||||
|
HANDLE f = CreateFile(p, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
if (f != INVALID_HANDLE_VALUE) {
|
||||||
|
FILETIME crTime = getFileTime(my_times->actime);
|
||||||
|
FILETIME modTime = getFileTime(my_times->modtime);
|
||||||
|
SetFileTime(f, &crTime, NULL, &modTime);
|
||||||
|
CloseHandle(f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -73,6 +73,7 @@ int my_read( int fd, void *, unsigned int);
|
|||||||
int my_write( int fd, const void *, unsigned int);
|
int my_write( int fd, const void *, unsigned int);
|
||||||
int my_chsize( int fd, unsigned int size );
|
int my_chsize( int fd, unsigned int size );
|
||||||
int my_locking( int fd, int mode, long nbytes );
|
int my_locking( int fd, int mode, long nbytes );
|
||||||
|
int my_utime( const char *path, struct my_utimbuf * );
|
||||||
|
|
||||||
extern int my_errno;
|
extern int my_errno;
|
||||||
|
|
||||||
@ -92,6 +93,7 @@ extern int my_errno;
|
|||||||
#define write my_write
|
#define write my_write
|
||||||
#define ftruncate my_chsize
|
#define ftruncate my_chsize
|
||||||
#define locking my_locking
|
#define locking my_locking
|
||||||
|
#define utime my_utime
|
||||||
|
|
||||||
#undef errno
|
#undef errno
|
||||||
#define errno my_errno
|
#define errno my_errno
|
||||||
@ -116,6 +118,12 @@ struct my_stat {
|
|||||||
time_t st_ctime;
|
time_t st_ctime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct my_utimbuf
|
||||||
|
{
|
||||||
|
time_t actime; // access time
|
||||||
|
time_t modtime; // modification time
|
||||||
|
};
|
||||||
|
|
||||||
// Your compiler may have different "struct stat" -> edit "struct my_stat"
|
// Your compiler may have different "struct stat" -> edit "struct my_stat"
|
||||||
#define validate_stat_struct ( sizeof(struct my_stat) == sizeof(struct stat) )
|
#define validate_stat_struct ( sizeof(struct my_stat) == sizeof(struct stat) )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user