Transferred attrib implementation from CMD to ATTRIB. Added tests for attrib in /CMD/tests/

EG Galano eg.galano at gmail.com
Wed Mar 31 05:16:29 CDT 2010


---
 programs/attrib/attrib.h           |   38 ++++++++++++++++++++++++
 programs/cmd/tests/test_attrib.cmd |   57 ++++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 programs/attrib/attrib.h
 create mode 100644 programs/cmd/tests/test_attrib.cmd

diff --git a/programs/attrib/attrib.h b/programs/attrib/attrib.h
new file mode 100644
index 0000000..0d38dd5
--- /dev/null
+++ b/programs/attrib/attrib.h
@@ -0,0 +1,38 @@
+/*
+ * CMD - Wine-compatible command line interface.
+ *
+ * Copyright (C) 1999 D A Pickles
+ * Copyright (C) 2007 J Edmeades
+ *
+ * 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 <windows.h>
+#include <windef.h>
+
+/*Function prototypes*/
+void ATTRIB_setshow_attrib (int argc, WCHAR *argv[]);
+static void WCMD_output_asis_len(const WCHAR *message, int len, HANDLE device);
+void WCMD_output (const WCHAR *format, ...);
+WCHAR *WCMD_LoadMessage(UINT id);
+
+/*Globals and Macros */
+BOOL unicodePipes = FALSE;
+static char  *output_bufA = NULL;
+#define MAX_WRITECONSOLE_SIZE 65535
+
+/* Translated messages */
+#define ATTRIB_NYI              1009
+#define ATTRIB_FILENOTFOUND     1010
diff --git a/programs/cmd/tests/test_attrib.cmd b/programs/cmd/tests/test_attrib.cmd
new file mode 100644
index 0000000..3f4390a
--- /dev/null
+++ b/programs/cmd/tests/test_attrib.cmd
@@ -0,0 +1,57 @@
+echo Tests for ATTRIB
+SETLOCAL EnableDelayedExpansion
+
+ at echo off
+echo -----------ATTRIB Test 1-----------
+attrib
+if %errorlevel% == 0 (echo ATTRIB with no arguments seems to work
+) else (
+  echo ATTRIB with no arguments failed)
+
+echo -----------ATTRIB Test 2-----------
+echo Creating test file: test_temp.txt
+echo This is a test file > test_temp.txt
+if %errorlevel% == 0 (echo File created successfully
+) else (
+  echo ATTRIB Unable to generate test file)
+attrib +R test_temp.txt
+echo Trying to write to a read-only file
+echo Writing to file > test_temp.txt
+if %errorlevel% == 0 (echo ATTRIB with one flag and one target seems to work
+) else (
+  echo ATTRIB with one flag and one argument failed)
+attrib -R test_temp.txt
+
+echo -----------ATTRIB Test 3-----------
+echo Setting all permissions on test_temp.txt (+H +R +S +A)
+for %%W IN (+R +H +S +A) DO (
+  attrib %%W test_temp.txt
+  )
+for %%X in (test_temp.txt) DO (
+  echo File name	: %%~X
+  echo File attrib	: %%~aX)
+if %errorlevel% == 0 ( echo Setting a file's attributes seems to work
+) else (
+  Setting a file's attributes failed)
+
+echo -----------ATTRIB Test 4-----------
+echo Removing all permissions on test_temp.txt (-H -R -S -A)
+for %%W IN (-R -H -S -A) DO (
+  attrib %%W test_temp.txt
+  )
+for %%X in (test_temp.txt) DO (
+  echo File name	: %%~X
+  echo File attrib	: %%~aX)
+if %errorlevel% == 0 ( echo Removing a file's attributes seems to work
+) else (
+  Removing a file's attributes failed)
+
+echo ----------ATTRIB Test 5------------
+echo Checking attributes on a file
+attrib test_temp.txt
+if %errorlevel% == 0 ( echo Checking a file's attributes seems to work
+) else (
+  Checking a file's attributes failed)
+
+del test_temp.txt
+endlocal
-- 
1.6.3.3


--=-Pb9/Tv3ERMix6ReMZgel--




More information about the wine-patches mailing list