From 546d80e194ac5fe9588bde6cd9ca0291476115a1 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 25 Jan 2018 19:03:10 +0100 Subject: [PATCH] Windows: remove symlink() usage in edje_decc and evil binaries --- src/Makefile_Evil.am | 2 - src/bin/edje/edje_decc.c | 4 +- src/bin/evil/evil_suite.c | 2 - src/bin/evil/evil_test_link.c | 159 ------------------------------------------ src/bin/evil/evil_test_link.h | 8 --- 5 files changed, 3 insertions(+), 172 deletions(-) delete mode 100644 src/bin/evil/evil_test_link.c delete mode 100644 src/bin/evil/evil_test_link.h diff --git a/src/Makefile_Evil.am b/src/Makefile_Evil.am index b5c7f02..93e5b1d 100644 --- a/src/Makefile_Evil.am +++ b/src/Makefile_Evil.am @@ -83,7 +83,6 @@ bin/evil/evil_suite.c \ bin/evil/evil_test_dlfcn.c \ bin/evil/evil_test_environment.c \ bin/evil/evil_test_gettimeofday.c \ -bin/evil/evil_test_link.c \ bin/evil/evil_test_mkstemp.c \ bin/evil/evil_test_pipe.c \ bin/evil/evil_test_print.c \ @@ -93,7 +92,6 @@ bin/evil/evil_suite.h \ bin/evil/evil_test_dlfcn.h \ bin/evil/evil_test_environment.h \ bin/evil/evil_test_gettimeofday.h \ -bin/evil/evil_test_link.h \ bin/evil/evil_test_mkstemp.h \ bin/evil/evil_test_pipe.h \ bin/evil/evil_test_print.h \ diff --git a/src/bin/edje/edje_decc.c b/src/bin/edje/edje_decc.c index fdbc903..5327897 100644 --- a/src/bin/edje/edje_decc.c +++ b/src/bin/edje/edje_decc.c @@ -126,7 +126,7 @@ main_help(void) ("Usage:\n" "\t%s input_file.edj [-main-out file.edc] [-no-build-sh] [-current-dir | -output path_to_dir]\n" "\n" - " -main-out\tCreate a symbolic link to the main edc \n" + " -main-out\tCreate a symbolic link to the main edc (disabled on Windows) \n" " -no-build-sh\tDon't output build.sh \n" " -output, -o\tOutput to specified directory \n" " -current-dir\tOutput to current directory \n" @@ -173,7 +173,9 @@ main(int argc, char **argv) else if ((!strcmp(argv[i], "-main-out")) && (i < (argc - 1))) { i++; +#ifndef _WIN32 file_out = argv[i]; +#endif } else if (!strcmp(argv[i], "-no-build-sh")) build_sh = 0; diff --git a/src/bin/evil/evil_suite.c b/src/bin/evil/evil_suite.c index 07b7758..6202fb4 100644 --- a/src/bin/evil/evil_suite.c +++ b/src/bin/evil/evil_suite.c @@ -14,7 +14,6 @@ #include "evil_test_dlfcn.h" #include "evil_test_environment.h" #include "evil_test_gettimeofday.h" -#include "evil_test_link.h" #include "evil_test_mkstemp.h" #include "evil_test_pipe.h" #include "evil_test_print.h" @@ -182,7 +181,6 @@ main(void) { "dlfcn ", test_dlfcn }, { "environment ", test_environment }, { "gettimeofday", test_gettimeofday }, - { "link ", test_link }, { "mkstemp ", test_mkstemp }, { "pipe ", test_pipe }, { "print ", test_print }, diff --git a/src/bin/evil/evil_test_link.c b/src/bin/evil/evil_test_link.c deleted file mode 100644 index 0aa4966..0000000 --- a/src/bin/evil/evil_test_link.c +++ /dev/null @@ -1,159 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include - -#include - -#include "evil_suite.h" -#include "evil_test_link.h" - -static int -test_link_test_file_create(const char *name, const char *data) -{ - FILE *f; - size_t length; - size_t res; - - f = fopen(name, "wb"); - if (!f) - return 0; - - length = strlen(data) + 1; - res = fwrite(data, 1, length, f); - if (res < length) - { - fclose(f); - return 0; - } - - fclose(f); - - return 1; -} - -static int -test_link_test_symlink(void) -{ -#ifdef _WIN32_WCE - const char *old_name = "\\efl\\evil_test_link.dat"; - const char *new_name = "\\efl\\evil_test_link.lnk"; -#else - const char *old_name = "evil_test_link.dat"; - const char *new_name = "evil_test_link.lnk"; -#endif - - if (!test_link_test_file_create(old_name, - "evil_test_link symlink data\n")) - return 0; - - if (symlink(old_name, new_name) < 0) - { - unlink(old_name); - return 0; - } - - if (unlink(new_name) < 0) - { - unlink(old_name); - return 0; - } - - if (unlink(old_name) < 0) - return 0; - - return 1; -} - -static int -test_link_test_readlink(void) -{ - char buf[1024]; -#ifdef _WIN32_WCE - const char *old_name = "\\efl\\evil_test_link.dat"; - const char *new_name = "\\efl\\evil_test_link.lnk"; -#else - const char *old_name = "evil_test_link.dat"; - const char *new_name = "evil_test_link.lnk"; -#endif - const char *data = "evil_test_link symlink data\n"; - FILE *f; - ssize_t s1; - size_t s2; - int l; - - if (!test_link_test_file_create(old_name, data)) - return 0; - - if (symlink(old_name, new_name) < 0) - return 0; - - if ((s1 = readlink(new_name, buf, 1023)) < 0) - { - unlink(old_name); - unlink(new_name); - return 0; - } - - buf[s1] = '\0'; - - f = fopen(buf, "rb"); - if (!f) - { - unlink(old_name); - unlink(new_name); - return 0; - } - - l = strlen(data); - s2 = fread(buf, 1, l + 1, f); - - if ((int)s2 != (l + 1)) - { - fclose(f); - unlink(old_name); - unlink(new_name); - return 0; - } - - if (strcmp(buf, data)) - { - fclose(f); - unlink(old_name); - unlink(new_name); - return 0; - } - - fclose(f); - - if (unlink(new_name) < 0) - { - unlink(old_name); - return 0; - } - - if (unlink(old_name) < 0) - return 0; - - return 1; -} - -static int -test_link_tests_run(suite *s) -{ - int res; - - res = test_link_test_symlink(); - res &= test_link_test_readlink(); - - return res; -} - -int -test_link(suite *s) -{ - - return test_link_tests_run(s); -} diff --git a/src/bin/evil/evil_test_link.h b/src/bin/evil/evil_test_link.h deleted file mode 100644 index 6f8bfa2..0000000 --- a/src/bin/evil/evil_test_link.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EVIL_TEST_LINK_H__ -#define __EVIL_TEST_LINK_H__ - - -int test_link(suite *s); - - -#endif /* __EVIL_TEST_LINK_H__ */ -- 2.7.4