Fix the path translation in FormatEx (depends on unimplemented GetVolumeNameForVolume...
[reactos.git] / reactos / lib / fmifs / format.c
1 /* $Id$
2 *
3 * COPYING: See the top level directory
4 * PROJECT: ReactOS
5 * FILE: reactos/lib/fmifs/format.c
6 * DESCRIPTION: File management IFS utility functions
7 * PROGRAMMER: Emanuele Aliberti
8 * UPDATED
9 * 1999-02-16 (Emanuele Aliberti)
10 * Entry points added.
11 */
12 #include "precomp.h"
13
14 #define NDEBUG
15 #include <debug.h>
16
17
18 /* FMIFS.6 */
19 VOID STDCALL
20 Format (VOID)
21 {
22 }
23
24
25 /* FMIFS.7 */
26 VOID STDCALL
27 FormatEx (PWCHAR DriveRoot,
28 ULONG MediaFlag,
29 PWCHAR Format,
30 PWCHAR Label,
31 BOOLEAN QuickFormat,
32 ULONG ClusterSize,
33 PFMIFSCALLBACK Callback)
34 {
35 UNICODE_STRING usDriveRoot;
36 UNICODE_STRING usLabel;
37 BOOLEAN Argument = FALSE;
38 WCHAR VolumeName[MAX_PATH];
39 CURDIR CurDir;
40
41 if (_wcsnicmp(Format, L"FAT", 3) != 0)
42 {
43 /* Unknown file system */
44 Callback (DONE, /* Command */
45 0, /* DWORD Modifier */
46 &Argument); /* Argument */
47 }
48
49 if (!GetVolumeNameForVolumeMountPointW(DriveRoot, VolumeName, MAX_PATH) ||
50 !RtlDosPathNameToNtPathName_U(VolumeName, &usDriveRoot, NULL, &CurDir))
51 {
52 /* Report an error. */
53 Callback (DONE, /* Command */
54 0, /* DWORD Modifier */
55 &Argument); /* Argument */
56
57 return;
58 }
59
60 RtlInitUnicodeString(&usLabel, Label);
61
62 if (_wcsnicmp(Format, L"FAT", 3) == 0)
63 {
64 DPRINT1("FormatEx - FAT\n");
65
66 VfatInitialize ();
67 VfatFormat (&usDriveRoot,
68 MediaFlag,
69 &usLabel,
70 QuickFormat,
71 ClusterSize,
72 Callback);
73 VfatCleanup ();
74 RtlFreeUnicodeString(&usDriveRoot);
75 }
76 }
77
78 /* EOF */