summaryrefslogtreecommitdiff
path: root/testing/tox_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tox_sync.c')
-rw-r--r--testing/tox_sync.c11
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
47typedef struct { 50typedef 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] == '/') {