ReactOS 0.4.15-dev-8222-g9164419
hardlink.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS FS utility tool
4 * FILE: base/applications/cmdutils/hardlink.c
5 * PURPOSE: FSutil hard links handling
6 * PROGRAMMERS: Pierre Schweitzer <pierre@reactos.org>
7 */
8
9#include "fsutil.h"
10
11/* Add handlers here for subcommands */
14{
15 /* Proc, name, help */
16 { CreateMain, _T("create"), _T("Create a new hard link") },
17};
18
19static int
20CreateMain(int argc, const TCHAR *argv[])
21{
23
24 /* We need a source and a destination */
25 if (argc < 3)
26 {
27 _ftprintf(stderr, _T("Usage: fsutil hardlink create <new> <existing>\n"));
28 _ftprintf(stderr, _T("\tFor example: fsutil hardlink create c:\\target.txt c:\\source.txt\n"));
29 return 1;
30 }
31
32 /* Get full names */
33 if (GetFullPathName(argv[1], MAX_PATH, Target, NULL) == 0)
34 {
36 return 1;
37 }
38
39 if (GetFullPathName(argv[2], MAX_PATH, Source, NULL) == 0)
40 {
42 return 1;
43 }
44
45 /* Simply delegate to kernel32 */
46 if (!CreateHardLink(Target, Source, NULL))
47 {
49 return 1;
50 }
51
52 /* Print the status */
53 _ftprintf(stdout, _T("Hard link created for %s <=> %s\n"), Target, Source);
54
55 return 0;
56}
57
58static void
60{
62 (sizeof(HandlersList) / sizeof(HandlersList[0])));
63}
64
65int
67{
69 (sizeof(HandlersList) / sizeof(HandlersList[0])),
71}
static int argc
Definition: ServiceArgs.c:12
HandlerProc HardLinkMain
Definition: fsutil.c:14
int() HandlerProc(int argc, const TCHAR *argv[])
Definition: fsutil.h:8
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
void PrintDefaultUsage(const TCHAR *Command, const TCHAR *SubCommand, HandlerItem *HandlersList, int HandlerListCount)
Definition: common.c:102
int FindHandler(int argc, const TCHAR *argv[], HandlerItem *HandlersList, int HandlerListCount, void(*UsageHelper)(const TCHAR *))
Definition: common.c:11
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define stdout
Definition: stdio.h:99
#define stderr
Definition: stdio.h:100
#define _ftprintf
Definition: tchar.h:518
#define argv
Definition: mplay32.c:18
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
void PrintUsage()
Definition: nslookup.c:68
Definition: shell.h:41
#define _T(x)
Definition: vfdio.h:22
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetFullPathName
Definition: winbase.h:3821
char TCHAR
Definition: xmlstorage.h:189