Skip to content

Commit 4166e67

Browse files
committed
Remove/Change some code
Yes, I couldnt figure out what to call this commit so I put in a generic one instead
1 parent 7329538 commit 4166e67

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

FileSystem.cc

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -105,55 +105,32 @@ namespace {
105105
#else
106106
FILETIME ft;
107107
GetSystemTimeAsFileTime(&ft);
108-
LARGE_INTEGER li;
109-
li.HighPart = ft.dwHighDateTime;
110-
li.LowPart = ft.dwLowDateTime;
111-
li.QuadPart -= 116444736000000000;
112-
fts->tv_sec = li.QuadPart / 10000000;
113-
fts->tv_nsec = (li.QuadPart % 10000000) * 100;
108+
fs_time_t time = (((fs_time_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime) - 116444736000000000;
109+
fts->tv_sec = time / 10000000;
110+
fts->tv_nsec = (time % 10000000) * 100;
114111
#endif
115112
}
116113

117114
#ifdef _WIN32
118115
fs_ssize_t WriteToFile(HANDLE handle, void* data, fs_size_t size) {
119116
DWORD written = 0;
120-
fs_size_t actualWritten = 0;
121117
BOOL res = WriteFile(handle, data, size, &written, NULL);
122118
if (!res)
123119
return -1;
124-
actualWritten = written;
125-
size -= actualWritten;
126-
if (size != 0) {
127-
data = (char*)data + actualWritten;
128-
res = WriteFile(handle, data, size, &written, NULL);
129-
if (!res)
130-
return -1;
131-
actualWritten += written;
132-
}
133-
return actualWritten;
120+
return written;
134121
}
135122
fs_ssize_t ReadFromFile(HANDLE handle, void* data, fs_size_t size) {
136-
DWORD read = 0;
137-
fs_size_t actualRead = 0;
123+
DWORD read = 0;
138124
BOOL res = ReadFile(handle, data, size, &read, NULL);
139125
if (!res)
140126
return -1;
141-
actualRead = read;
142-
size -= actualRead;
143-
if (size != 0) {
144-
data = (char*)data + actualRead;
145-
res = ReadFile(handle, data, size, &read, NULL);
146-
if (!res)
147-
return -1;
148-
actualRead += read;
149-
}
150-
return actualRead;
127+
return read;
151128
}
152129
#endif
153130

154131
class ScopedLock {
155-
#ifdef __linux__
156132
public:
133+
#ifdef __linux__
157134
ScopedLock(pthread_mutex_t& mtx) {
158135
mtx_ = &mtx;
159136
pthread_mutex_lock(&mtx);
@@ -164,7 +141,6 @@ namespace {
164141
private:
165142
pthread_mutex_t* mtx_;
166143
#else
167-
public:
168144
ScopedLock(HANDLE mtx) {
169145
mtx_ = mtx;
170146
WaitForSingleObject(mtx, INFINITE);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daisydogs07/filesystem",
3-
"version": "5.2.11",
3+
"version": "5.2.12",
44
"os": ["linux", "win32"],
55
"cpu": ["x64"],
66
"keywords": [

0 commit comments

Comments
 (0)