mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
[FSUTIL]
Implement fsutil hardlink create svn path=/trunk/; revision=75804
This commit is contained in:
parent
e1ea305c4d
commit
dc1e7928d0
3 changed files with 74 additions and 0 deletions
|
@ -3,6 +3,7 @@ list(APPEND SOURCE
|
|||
dirty.c
|
||||
fsinfo.c
|
||||
fsutil.c
|
||||
hardlink.c
|
||||
fsutil.h)
|
||||
add_executable(fsutil ${SOURCE} fsutil.rc)
|
||||
set_module_type(fsutil win32cui UNICODE)
|
||||
|
|
|
@ -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
|
||||
|
|
71
reactos/base/applications/cmdutils/fsutil/hardlink.c
Normal file
71
reactos/base/applications/cmdutils/fsutil/hardlink.c
Normal file
|
@ -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@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);
|
||||
}
|
Loading…
Reference in a new issue