[MOVEFILE]
authorPierre Schweitzer <pierre@reactos.org>
Sun, 13 Aug 2017 10:15:55 +0000 (10:15 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 13 Aug 2017 10:15:55 +0000 (10:15 +0000)
Open source the movefile utily that allows queueing deletion/renaming operations for the next reboot

svn path=/trunk/; revision=75531

rosapps/applications/rosinternals/CMakeLists.txt
rosapps/applications/rosinternals/movefile/CMakeLists.txt [new file with mode: 0644]
rosapps/applications/rosinternals/movefile/movefile.c [new file with mode: 0644]
rosapps/applications/rosinternals/movefile/movefile.rc [new file with mode: 0644]

index 5aa7fbe..1932f92 100644 (file)
@@ -1,2 +1,3 @@
+add_subdirectory(movefile)
 add_subdirectory(ntfsinfo)
 add_subdirectory(pendmoves)
diff --git a/rosapps/applications/rosinternals/movefile/CMakeLists.txt b/rosapps/applications/rosinternals/movefile/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ccf0999
--- /dev/null
@@ -0,0 +1,5 @@
+list(APPEND SOURCE movefile.c movefile.rc)
+add_executable(movefile ${SOURCE})
+set_module_type(movefile win32cui UNICODE)
+add_importlibs(movefile msvcrt kernel32 ntdll)
+add_cd_file(TARGET movefile DESTINATION reactos/system32 FOR all)
diff --git a/rosapps/applications/rosinternals/movefile/movefile.c b/rosapps/applications/rosinternals/movefile/movefile.c
new file mode 100644 (file)
index 0000000..2559e70
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS pending moves operations interactions tool
+ * FILE:            cmdutils/movefile/movefile.c
+ * PURPOSE:         Queue move operations for next reboot
+ * PROGRAMMERS:     Pierre Schweitzer <pierre@reactos.org>
+ */
+
+#include <windows.h>
+#include <tchar.h>
+#include <stdio.h>
+
+int
+__cdecl
+_tmain(int argc, const TCHAR *argv[])
+{
+    /* We need source + target */
+    if (argc < 3)
+    {
+        _ftprintf(stderr, _T("Missing arguments\nUsage: %s source target\nUse \"\" as target is you want deletion\n"), argv[0]);
+        return 1;
+    }
+
+    /* If target is empty, it means deletion, so provide null pointer */
+    if (!MoveFileEx(argv[1], (argv[2][0] == 0 ? NULL : argv[2]), MOVEFILE_DELAY_UNTIL_REBOOT))
+    {
+        _ftprintf(stderr, _T("Error: %d\n"), GetLastError());
+        return 1;
+    }
+
+    return 0;
+}
diff --git a/rosapps/applications/rosinternals/movefile/movefile.rc b/rosapps/applications/rosinternals/movefile/movefile.rc
new file mode 100644 (file)
index 0000000..b22d7cb
--- /dev/null
@@ -0,0 +1,4 @@
+#define REACTOS_STR_FILE_DESCRIPTION    "Queue move operations for next reboot\0"
+#define REACTOS_STR_INTERNAL_NAME       "movefile\0"
+#define REACTOS_STR_ORIGINAL_FILENAME   "movefile.exe\0"
+#include <reactos/version.rc>