21 |
#include <string.h> |
#include <string.h> |
22 |
#include <ctype.h> |
#include <ctype.h> |
23 |
|
|
24 |
|
#include <glib.h> |
25 |
|
#include <glib/gstdio.h> |
26 |
|
|
27 |
#include "gpxview.h" |
#include "gpxview.h" |
28 |
|
|
29 |
char strlastchr(char *str) { |
char strlastchr(char *str) { |
388 |
} |
} |
389 |
#endif |
#endif |
390 |
#endif |
#endif |
391 |
|
|
392 |
|
/* recursively remove an entire file system */ |
393 |
|
void rmdir_recursive(char *path) { |
394 |
|
GDir *dir = g_dir_open(path, 0, NULL); |
395 |
|
if(dir) { |
396 |
|
const char *name = g_dir_read_name(dir); |
397 |
|
while(name) { |
398 |
|
char *fullname = g_strdup_printf("%s/%s", path, name); |
399 |
|
// printf("deleting %s\n", fullname); |
400 |
|
|
401 |
|
if(g_file_test(fullname, G_FILE_TEST_IS_DIR)) |
402 |
|
rmdir_recursive(fullname); |
403 |
|
else if(g_file_test(fullname, G_FILE_TEST_IS_REGULAR)) |
404 |
|
g_remove(fullname); |
405 |
|
|
406 |
|
g_free(fullname); |
407 |
|
name = g_dir_read_name(dir); |
408 |
|
} |
409 |
|
|
410 |
|
g_dir_close(dir); |
411 |
|
} |
412 |
|
g_rmdir(path); |
413 |
|
} |
414 |
|
|