[PATCH 1/2] fsutil: Print out usage message
Arkadiusz Hiler
ahiler at codeweavers.com
Tue Aug 4 10:05:45 CDT 2020
From: Michael Müller <michael at fds-team.de>
Fsutil doesn't do anything yet other than printing out usage message. This
patch puts some thing in place in preparation for the implementation of
hardlink subcommand.
Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
Signed-off-by: Arkadiusz Hiler <ahiler at codeweavers.com>
---
programs/fsutil/Makefile.in | 4 +++
programs/fsutil/fsutil.mc | 27 ++++++++++++++++
programs/fsutil/main.c | 63 ++++++++++++++++++++++++++++++++++---
programs/fsutil/resources.h | 21 +++++++++++++
4 files changed, 110 insertions(+), 5 deletions(-)
create mode 100644 programs/fsutil/fsutil.mc
create mode 100644 programs/fsutil/resources.h
diff --git a/programs/fsutil/Makefile.in b/programs/fsutil/Makefile.in
index 64307e83ac..fe736bad5d 100644
--- a/programs/fsutil/Makefile.in
+++ b/programs/fsutil/Makefile.in
@@ -1,6 +1,10 @@
MODULE = fsutil.exe
+IMPORTS = user32
EXTRADLLFLAGS = -mconsole -municode -mno-cygwin
C_SRCS = \
main.c
+
+MC_SRCS = \
+ fsutil.mc
diff --git a/programs/fsutil/fsutil.mc b/programs/fsutil/fsutil.mc
new file mode 100644
index 0000000000..54c801cb2b
--- /dev/null
+++ b/programs/fsutil/fsutil.mc
@@ -0,0 +1,27 @@
+;
+; Copyright 2020 Arkadiusz Hiler for CodeWeavers
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Lesser General Public
+; License as published by the Free Software Foundation; either
+; version 2.1 of the License, or (at your option) any later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+;
+
+LanguageNames=(ENU=0x409:fsutil)
+
+MessageId=101
+SymbolicName=STRING_USAGE
+Language=ENU
+- Supported Commands -
+
+[NONE]
+.
diff --git a/programs/fsutil/main.c b/programs/fsutil/main.c
index eb4e341297..1d61edab75 100644
--- a/programs/fsutil/main.c
+++ b/programs/fsutil/main.c
@@ -1,5 +1,6 @@
/*
* Copyright 2016 Austin English
+ * Copyright 2016 Michael Müller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -16,18 +17,70 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <windows.h>
+
#include "wine/debug.h"
+#include "resources.h"
WINE_DEFAULT_DEBUG_CHANNEL(fsutil);
+static void output_write(const WCHAR *str, DWORD wlen)
+{
+ DWORD count, ret;
+
+ ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, wlen, &count, NULL);
+ if (!ret)
+ {
+ DWORD len;
+ char *msgA;
+
+ /* On Windows WriteConsoleW() fails if the output is redirected. So fall
+ * back to WriteFile(), assuming the console encoding is still the right
+ * one in that case.
+ */
+ len = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, NULL, 0, NULL, NULL);
+ msgA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
+ if (!msgA) return;
+
+ WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, msgA, len, NULL, NULL);
+ WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE);
+ HeapFree(GetProcessHeap(), 0, msgA);
+ }
+}
+
+static int WINAPIV output_string(int msg, ...)
+{
+ WCHAR out[8192];
+ __ms_va_list arguments;
+ int len;
+
+ __ms_va_start(arguments, msg);
+ len = FormatMessageW(FORMAT_MESSAGE_FROM_HMODULE, NULL, msg, 0, out, ARRAY_SIZE(out), &arguments);
+ __ms_va_end(arguments);
+
+ if (len == 0 && GetLastError() != NO_ERROR)
+ WINE_FIXME("Could not format string: le=%u, msg=%d\n", GetLastError(), msg);
+ else
+ output_write(out, len);
+
+ return 0;
+}
+
int __cdecl wmain(int argc, WCHAR *argv[])
{
- int i;
+ int i, ret = 0;
- WINE_FIXME("stub:");
+ TRACE("Command line:");
for (i = 0; i < argc; i++)
- WINE_FIXME(" %s", wine_dbgstr_w(argv[i]));
- WINE_FIXME("\n");
+ TRACE(" %s", debugstr_w(argv[i]));
+ TRACE("\n");
- return 0;
+ if (argc > 1)
+ {
+ FIXME("unsupported command %s\n", debugstr_w(argv[1]));
+ ret = 1;
+ }
+
+ output_string(STRING_USAGE);
+ return ret;
}
diff --git a/programs/fsutil/resources.h b/programs/fsutil/resources.h
new file mode 100644
index 0000000000..36b0ffc35f
--- /dev/null
+++ b/programs/fsutil/resources.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016 Michael Müller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windef.h>
+
+#define STRING_USAGE 101
--
2.28.0
More information about the wine-devel
mailing list