Author: pschweitzer
Date: Fri Sep 8 20:51:16 2017
New Revision: 75804
URL:
http://svn.reactos.org/svn/reactos?rev=75804&view=rev
Log:
[FSUTIL]
Implement fsutil hardlink create
Added:
trunk/reactos/base/applications/cmdutils/fsutil/hardlink.c (with props)
Modified:
trunk/reactos/base/applications/cmdutils/fsutil/CMakeLists.txt
trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c
Modified: trunk/reactos/base/applications/cmdutils/fsutil/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/fsutil/CMakeLists.txt [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/cmdutils/fsutil/CMakeLists.txt [iso-8859-1] Fri Sep 8
20:51:16 2017
@@ -3,6 +3,7 @@
dirty.c
fsinfo.c
fsutil.c
+ hardlink.c
fsutil.h)
add_executable(fsutil ${SOURCE} fsutil.rc)
set_module_type(fsutil win32cui UNICODE)
Modified: trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c [iso-8859-1] Fri Sep 8
20:51:16 2017
@@ -11,11 +11,13 @@
/* Add handlers here for commands */
int DirtyMain(int argc, const TCHAR *argv[]);
int FsInfoMain(int argc, const TCHAR *argv[]);
+int HardLinkMain(int argc, const TCHAR *argv[]);
static HandlerItem HandlersList[] =
{
/* Proc, name, help */
{ DirtyMain, _T("dirty"), _T("Manipulates the dirty bit") },
{ FsInfoMain, _T("fsinfo"), _T("Gathers informations about file
systems") },
+ { HardLinkMain, _T("hardlink"), _T("Handles hard links") },
};
static void
Added: trunk/reactos/base/applications/cmdutils/fsutil/hardlink.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/fsutil/hardlink.c (added)
+++ trunk/reactos/base/applications/cmdutils/fsutil/hardlink.c [iso-8859-1] Fri Sep 8
20:51:16 2017
@@ -0,0 +1,71 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS FS utility tool
+ * FILE: base/applications/cmdutils/hardlink.c
+ * PURPOSE: FSutil hard links handling
+ * PROGRAMMERS: Pierre Schweitzer <pierre(a)reactos.org>
+ */
+
+#include "fsutil.h"
+
+/* Add handlers here for subcommands */
+static int CreateMain(int argc, const TCHAR *argv[]);
+static HandlerItem HandlersList[] =
+{
+ /* Proc, name, help */
+ { CreateMain, _T("create"), _T("Create a new hard link") },
+};
+
+static int
+CreateMain(int argc, const TCHAR *argv[])
+{
+ TCHAR Source[MAX_PATH], Target[MAX_PATH];
+
+ /* We need a source and a destination */
+ if (argc < 3)
+ {
+ _ftprintf(stderr, _T("Usage: fsutil hardlink create <new>
<existing>\n"));
+ _ftprintf(stderr, _T("\tFor example: fsutil hardlink create c:\\target.txt
c:\\source.txt\n"));
+ return 1;
+ }
+
+ /* Get full names */
+ if (GetFullPathName(argv[1], MAX_PATH, Target, NULL) == 0)
+ {
+ PrintErrorMessage(GetLastError());
+ return 1;
+ }
+
+ if (GetFullPathName(argv[2], MAX_PATH, Source, NULL) == 0)
+ {
+ PrintErrorMessage(GetLastError());
+ return 1;
+ }
+
+ /* Simply delegate to kernel32 */
+ if (!CreateHardLink(Target, Source, NULL))
+ {
+ PrintErrorMessage(GetLastError());
+ return 1;
+ }
+
+ /* Print the status */
+ _ftprintf(stdout, _T("Hard link created for %s <=> %s\n"), Target,
Source);
+
+ return 0;
+}
+
+static void
+PrintUsage(const TCHAR * Command)
+{
+ PrintDefaultUsage(_T(" HARDLINK "), Command, (HandlerItem
*)&HandlersList,
+ (sizeof(HandlersList) / sizeof(HandlersList[0])));
+}
+
+int
+HardLinkMain(int argc, const TCHAR *argv[])
+{
+ return FindHandler(argc, argv, (HandlerItem *)&HandlersList,
+ (sizeof(HandlersList) / sizeof(HandlersList[0])),
+ PrintUsage);
+}
Propchange: trunk/reactos/base/applications/cmdutils/fsutil/hardlink.c
------------------------------------------------------------------------------
svn:eol-style = native