diff options
author | David Zero <zero@cpp.edu> | 2017-01-06 04:19:12 -0800 |
---|---|---|
committer | David Zero <zero@cpp.edu> | 2017-01-06 04:20:00 -0800 |
commit | 8ef1f35ca71e39d40bdae88243534eebc6fa6a26 (patch) | |
tree | c3615a0cfb3249ed524f5aeb3c5df7511bb6d268 /testing/tox_sync.c | |
parent | 08cd61387ee078b81c50fa2714e9f1534a0865a2 (diff) |
Revert "Revert "Portability fixes""
This reverts commit 59e2a844f04a8725e8079f854158aa86ef5988b2, and
defines _DARWIN_C_SOURCE in toxcore/network.c
Diffstat (limited to 'testing/tox_sync.c')
-rw-r--r-- | testing/tox_sync.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/testing/tox_sync.c b/testing/tox_sync.c index 0c91abfd..6ac3dcf0 100644 --- a/testing/tox_sync.c +++ b/testing/tox_sync.c | |||
@@ -28,6 +28,8 @@ | |||
28 | * | 28 | * |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #define _XOPEN_SOURCE 600 | ||
32 | |||
31 | #ifdef HAVE_CONFIG_H | 33 | #ifdef HAVE_CONFIG_H |
32 | #include "config.h" | 34 | #include "config.h" |
33 | #endif | 35 | #endif |
@@ -42,6 +44,7 @@ | |||
42 | #include <dirent.h> | 44 | #include <dirent.h> |
43 | #include <netinet/in.h> | 45 | #include <netinet/in.h> |
44 | #include <stdio.h> | 46 | #include <stdio.h> |
47 | #include <sys/stat.h> | ||
45 | 48 | ||
46 | #define NUM_FILE_SENDERS 256 | 49 | #define NUM_FILE_SENDERS 256 |
47 | typedef struct { | 50 | typedef struct { |
@@ -297,6 +300,7 @@ int main(int argc, char *argv[]) | |||
297 | memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4])); | 300 | memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4])); |
298 | DIR *d; | 301 | DIR *d; |
299 | struct dirent *dir; | 302 | struct dirent *dir; |
303 | struct stat statbuf; | ||
300 | uint8_t notconnected = 1; | 304 | uint8_t notconnected = 1; |
301 | 305 | ||
302 | while (1) { | 306 | while (1) { |
@@ -310,7 +314,12 @@ int main(int argc, char *argv[]) | |||
310 | 314 | ||
311 | if (d) { | 315 | if (d) { |
312 | while ((dir = readdir(d)) != NULL) { | 316 | while ((dir = readdir(d)) != NULL) { |
313 | if (dir->d_type == DT_REG) { | 317 | char filepath[strlen(path) + strlen(dir->d_name) + 1]; |
318 | memcpy(filepath, path, strlen(path)); | ||
319 | memcpy(filepath + strlen(path), dir->d_name, strlen(dir->d_name) + 1); | ||
320 | stat(filepath, &statbuf); | ||
321 | |||
322 | if (S_ISREG(statbuf.st_mode)) { | ||
314 | char fullpath[1024]; | 323 | char fullpath[1024]; |
315 | 324 | ||
316 | if (path[strlen(path) - 1] == '/') { | 325 | if (path[strlen(path) - 1] == '/') { |