diff options
author | ng0 <ng0@n0.is> | 2019-09-10 16:59:32 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-10 16:59:32 +0000 |
commit | 04b6df21cd281e8cd540139f8d9ae85defc1961c (patch) | |
tree | 6357199445df8d5c0c631bc8f10aef838b1f9f1e /src/util/disk.c | |
parent | 483b0139a218a5f8a8311bda3eb23bcd88f57688 (diff) | |
download | gnunet-04b6df21cd281e8cd540139f8d9ae85defc1961c.tar.gz gnunet-04b6df21cd281e8cd540139f8d9ae85defc1961c.zip |
remove CYGWIN codeblocks, drop vendored Windows openvpn, drop win32 specific files.
configures and builds okay.
testsuite wasn't checked, will be checked.
diff including the plibc removal is now around 14370 lines of code less.
Diffstat (limited to 'src/util/disk.c')
-rw-r--r-- | src/util/disk.c | 88 |
1 files changed, 1 insertions, 87 deletions
diff --git a/src/util/disk.c b/src/util/disk.c index 01d5efbe2..8b474542b 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -96,7 +96,6 @@ struct GetFileSizeData { | |||
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | #ifndef MINGW | ||
100 | /** | 99 | /** |
101 | * Translate GNUnet-internal permission bitmap to UNIX file | 100 | * Translate GNUnet-internal permission bitmap to UNIX file |
102 | * access permission bitmap. | 101 | * access permission bitmap. |
@@ -131,7 +130,6 @@ translate_unix_perms(enum GNUNET_DISK_AccessPermissions perm) | |||
131 | 130 | ||
132 | return mode; | 131 | return mode; |
133 | } | 132 | } |
134 | #endif | ||
135 | 133 | ||
136 | 134 | ||
137 | /** | 135 | /** |
@@ -191,11 +189,7 @@ getSizeRec(void *cls, const char *fn) | |||
191 | int | 189 | int |
192 | GNUNET_DISK_handle_invalid(const struct GNUNET_DISK_FileHandle *h) | 190 | GNUNET_DISK_handle_invalid(const struct GNUNET_DISK_FileHandle *h) |
193 | { | 191 | { |
194 | #ifdef MINGW | ||
195 | return ((!h) || (h->h == INVALID_HANDLE_VALUE)) ? GNUNET_YES : GNUNET_NO; | ||
196 | #else | ||
197 | return ((!h) || (h->fd == -1)) ? GNUNET_YES : GNUNET_NO; | 192 | return ((!h) || (h->fd == -1)) ? GNUNET_YES : GNUNET_NO; |
198 | #endif | ||
199 | } | 193 | } |
200 | 194 | ||
201 | /** | 195 | /** |
@@ -236,26 +230,9 @@ GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, | |||
236 | return GNUNET_SYSERR; | 230 | return GNUNET_SYSERR; |
237 | } | 231 | } |
238 | 232 | ||
239 | #ifdef MINGW | ||
240 | LARGE_INTEGER li; | ||
241 | LARGE_INTEGER new_pos; | ||
242 | BOOL b; | ||
243 | |||
244 | static DWORD t[] = { FILE_BEGIN, FILE_CURRENT, FILE_END }; | ||
245 | li.QuadPart = offset; | ||
246 | |||
247 | b = SetFilePointerEx(h->h, li, &new_pos, t[whence]); | ||
248 | if (b == 0) | ||
249 | { | ||
250 | SetErrnoFromWinError(GetLastError()); | ||
251 | return GNUNET_SYSERR; | ||
252 | } | ||
253 | return (off_t)new_pos.QuadPart; | ||
254 | #else | ||
255 | static int t[] = { SEEK_SET, SEEK_CUR, SEEK_END }; | 233 | static int t[] = { SEEK_SET, SEEK_CUR, SEEK_END }; |
256 | 234 | ||
257 | return lseek(h->fd, offset, t[whence]); | 235 | return lseek(h->fd, offset, t[whence]); |
258 | #endif | ||
259 | } | 236 | } |
260 | 237 | ||
261 | 238 | ||
@@ -1296,7 +1273,7 @@ GNUNET_DISK_file_open(const char *fn, | |||
1296 | expfn = GNUNET_STRINGS_filename_expand(fn); | 1273 | expfn = GNUNET_STRINGS_filename_expand(fn); |
1297 | if (NULL == expfn) | 1274 | if (NULL == expfn) |
1298 | return NULL; | 1275 | return NULL; |
1299 | #ifndef MINGW | 1276 | |
1300 | mode = 0; | 1277 | mode = 0; |
1301 | if (GNUNET_DISK_OPEN_READWRITE == (flags & GNUNET_DISK_OPEN_READWRITE)) | 1278 | if (GNUNET_DISK_OPEN_READWRITE == (flags & GNUNET_DISK_OPEN_READWRITE)) |
1302 | oflags = O_RDWR; /* note: O_RDWR is NOT always O_RDONLY | O_WRONLY */ | 1279 | oflags = O_RDWR; /* note: O_RDWR is NOT always O_RDONLY | O_WRONLY */ |
@@ -1342,69 +1319,6 @@ GNUNET_DISK_file_open(const char *fn, | |||
1342 | GNUNET_free(expfn); | 1319 | GNUNET_free(expfn); |
1343 | return NULL; | 1320 | return NULL; |
1344 | } | 1321 | } |
1345 | #else | ||
1346 | access = 0; | ||
1347 | disp = OPEN_ALWAYS; | ||
1348 | |||
1349 | if (GNUNET_DISK_OPEN_READWRITE == (flags & GNUNET_DISK_OPEN_READWRITE)) | ||
1350 | access = FILE_READ_DATA | FILE_WRITE_DATA; | ||
1351 | else if (flags & GNUNET_DISK_OPEN_READ) | ||
1352 | access = FILE_READ_DATA; | ||
1353 | else if (flags & GNUNET_DISK_OPEN_WRITE) | ||
1354 | access = FILE_WRITE_DATA; | ||
1355 | |||
1356 | if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS) | ||
1357 | { | ||
1358 | disp = CREATE_NEW; | ||
1359 | } | ||
1360 | else if (flags & GNUNET_DISK_OPEN_CREATE) | ||
1361 | { | ||
1362 | (void)GNUNET_DISK_directory_create_for_file(expfn); | ||
1363 | if (flags & GNUNET_DISK_OPEN_TRUNCATE) | ||
1364 | disp = CREATE_ALWAYS; | ||
1365 | else | ||
1366 | disp = OPEN_ALWAYS; | ||
1367 | } | ||
1368 | else if (flags & GNUNET_DISK_OPEN_TRUNCATE) | ||
1369 | { | ||
1370 | disp = TRUNCATE_EXISTING; | ||
1371 | } | ||
1372 | else | ||
1373 | { | ||
1374 | disp = OPEN_EXISTING; | ||
1375 | } | ||
1376 | |||
1377 | if (ERROR_SUCCESS == plibc_conv_to_win_pathwconv(expfn, wexpfn)) | ||
1378 | h = CreateFileW(wexpfn, | ||
1379 | access, | ||
1380 | FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, | ||
1381 | NULL, | ||
1382 | disp, | ||
1383 | FILE_ATTRIBUTE_NORMAL, | ||
1384 | NULL); | ||
1385 | else | ||
1386 | h = INVALID_HANDLE_VALUE; | ||
1387 | if (h == INVALID_HANDLE_VALUE) | ||
1388 | { | ||
1389 | int err; | ||
1390 | SetErrnoFromWinError(GetLastError()); | ||
1391 | err = errno; | ||
1392 | LOG_STRERROR_FILE(GNUNET_ERROR_TYPE_INFO, "open", expfn); | ||
1393 | GNUNET_free(expfn); | ||
1394 | errno = err; | ||
1395 | return NULL; | ||
1396 | } | ||
1397 | |||
1398 | if (flags & GNUNET_DISK_OPEN_APPEND) | ||
1399 | if (SetFilePointer(h, 0, 0, FILE_END) == INVALID_SET_FILE_POINTER) | ||
1400 | { | ||
1401 | SetErrnoFromWinError(GetLastError()); | ||
1402 | LOG_STRERROR_FILE(GNUNET_ERROR_TYPE_WARNING, "SetFilePointer", expfn); | ||
1403 | CloseHandle(h); | ||
1404 | GNUNET_free(expfn); | ||
1405 | return NULL; | ||
1406 | } | ||
1407 | #endif | ||
1408 | 1322 | ||
1409 | ret = GNUNET_new(struct GNUNET_DISK_FileHandle); | 1323 | ret = GNUNET_new(struct GNUNET_DISK_FileHandle); |
1410 | 1324 | ||