]> gitweb.factorcode.org Git - factor.git/commitdiff
Change the MOVE_FILE macro to a function named move_file
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 3 Feb 2010 21:12:13 +0000 (15:12 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 3 Feb 2010 21:12:13 +0000 (15:12 -0600)
vm/image.cpp
vm/os-unix.cpp
vm/os-unix.hpp
vm/os-windows.cpp
vm/os-windows.hpp
vm/vm.hpp

index ba9fb4e6e6eb9e253789efc8677e44cac4b65dc3..ad21270378ac24735b48e4150ad7c26dc04113a6 100755 (executable)
@@ -306,7 +306,7 @@ bool factor_vm::save_image(const vm_char *saving_filename, const vm_char *filena
        if(!ok)
                std::cout << "save-image failed: " << strerror(errno) << std::endl;
        else
-               MOVE_FILE(saving_filename,filename); 
+               move_file(saving_filename,filename); 
 
        return ok;
 }
index 4b5040ab8bd0d88c8a8abf2c2ae4af35589a7a82..15f8132a634e560e12db87c5bef62f0c9ac9971d 100644 (file)
@@ -96,6 +96,16 @@ void factor_vm::primitive_existsp()
        ctx->push(tag_boolean(stat(path,&sb) >= 0));
 }
 
+void factor_vm::move_file(const vm_char *path1, const vm_char *path2)
+{
+       int ret = 0;
+       do {
+               ret = rename((path1),(path2));
+       } while(ret < 0 && errno == EINTR);
+       if(ret < 0)
+               general_error(ERROR_IO,tag_fixnum(errno),false_object,NULL);
+}
+
 segment::segment(cell size_, bool executable_p)
 {
        size = size_;
index 5efa62919d477c5873ea4a76f04275f8c5182f64..29378bb52331bba35e2c298af705fdc42237949f 100644 (file)
@@ -31,15 +31,6 @@ typedef char symbol_char;
 
 #define OPEN_READ(path) fopen(path,"rb")
 #define OPEN_WRITE(path) fopen(path,"wb")
-#define MOVE_FILE(path1,path2) \
-do {\
-       int ret = 0;\
-       do {\
-               ret = rename((path1),(path2));\
-       } while(ret < 0 && errno == EINTR);\
-       if(ret < 0)\
-               general_error(ERROR_IO,tag_fixnum(errno),false_object,NULL);\
-}while(0)
 
 #define print_native_string(string) print_string(string)
 
@@ -62,4 +53,6 @@ void register_vm_with_thread(factor_vm *vm);
 factor_vm *tls_vm();
 void open_console();
 
+void move_file(const vm_char *path1, const vm_char *path2);
+
 }
index df2a57f2e80de2aa3fa51fd00675d57f4086b93c..c537148a540be3e3905646fe080ab6894ddcdc18 100755 (executable)
@@ -137,4 +137,8 @@ long getpagesize()
        return g_pagesize;
 }
 
+void factor_vm::move_file(const vm_char *path1, const vm_char *path2)
+{
+    if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false)
+               general_error(ERROR_IO,tag_fixnum(GetLastError()),false_object,NULL);
 }
index 30e3eea9c975b8933501318e10bc773f655d9e1e..92a3c73a99ed42f96c215bc995dacca2e48f9b0b 100755 (executable)
@@ -39,11 +39,6 @@ typedef wchar_t vm_char;
 
 #define OPEN_READ(path) _wfopen((path),L"rb")
 #define OPEN_WRITE(path) _wfopen((path),L"wb")
-#define MOVE_FILE(path1,path2)\
-do {\
-       if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false)\
-               std::cout << "MoveFile() failed: error " << GetLastError() << std::endl;\
-} while(0)
 
 /* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */
 #define EPOCH_OFFSET 0x019db1ded53e8000LL
@@ -55,5 +50,6 @@ u64 system_micros();
 u64 nano_count();
 void sleep_nanos(u64 nsec);
 long getpagesize();
+void move_file(const vm_char *path1, const vm_char *path2);
 
 }
index bdbd465d7848593b2122655f603070be2b587857..0ccf5020786d6b6925490c7ccfdf3d6c5febcb57 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -656,6 +656,7 @@ struct factor_vm
 
        // os-*
        void primitive_existsp();
+       void move_file(const vm_char *path1, const vm_char *path2);
        void init_ffi();
        void ffi_dlopen(dll *dll);
        void *ffi_dlsym(dll *dll, symbol_char *symbol);