Author: fireball
Date: Thu Feb 4 15:40:36 2010
New Revision: 45418
URL:
http://svn.reactos.org/svn/reactos?rev=45418&view=rev
Log:
[base/system/expand]
- Update expand utility to Wine-1.1.37. Last update happened 7 years ago and since then it
was translated into 20 languages. Sorry to all the translators but the preference is given
to a working untranslated version rather than a non-working localized one.
See issue #4637 for more details.
Removed:
trunk/reactos/base/system/expand/lang/
trunk/reactos/base/system/expand/resource.h
trunk/reactos/base/system/expand/rsrc.rc
Modified:
trunk/reactos/base/system/expand/expand.c
trunk/reactos/base/system/expand/expand.rbuild
trunk/reactos/base/system/expand/expand.rc
Modified: trunk/reactos/base/system/expand/expand.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/expand/expand.…
==============================================================================
--- trunk/reactos/base/system/expand/expand.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/expand/expand.c [iso-8859-1] Thu Feb 4 15:40:36 2010
@@ -1,6 +1,7 @@
/*
* Copyright 1997 Victor Schneider
* Copyright 2002 Alexandre Julliard
+ * Copyright 2007 Hans Leidekker
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -14,44 +15,178 @@
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <stdlib.h>
+#define WIN32_LEAN_AND_MEAN
+
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <lzexpand.h>
-#include <tchar.h>
+#include <setupapi.h>
-#include "resource.h"
+static UINT CALLBACK set_outfile( PVOID context, UINT notification, UINT_PTR param1,
UINT_PTR param2 )
+{
+ FILE_IN_CABINET_INFO_A *info = (FILE_IN_CABINET_INFO_A *)param1;
+ char buffer[MAX_PATH];
+ char* basename;
-int _tmain(int argc, TCHAR *argv[])
+ switch (notification)
+ {
+ case SPFILENOTIFY_FILEINCABINET:
+ {
+ LPSTR outfile = context;
+ if (outfile[0] != 0)
+ {
+ SetLastError( ERROR_NOT_SUPPORTED );
+ return FILEOP_ABORT;
+ }
+ GetFullPathNameA( info->NameInCabinet, sizeof(buffer), buffer, &basename
);
+ strcpy( outfile, basename );
+ return FILEOP_SKIP;
+ }
+ default: return NO_ERROR;
+ }
+}
+
+static UINT CALLBACK extract_callback( PVOID context, UINT notification, UINT_PTR param1,
UINT_PTR param2 )
{
- OFSTRUCT SourceOpenStruct1, SourceOpenStruct2;
- LONG ret;
- HFILE hSourceFile, hDestFile;
- TCHAR szMsg[RC_STRING_MAX_SIZE];
+ FILE_IN_CABINET_INFO_A *info = (FILE_IN_CABINET_INFO_A *)param1;
- if (argc < 2)
- {
- LoadString( GetModuleHandle(NULL), IDS_Copy, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);
- _ftprintf( stderr, szMsg, argv[0] );
- return 1;
- }
- hSourceFile = LZOpenFile(argv[1], &SourceOpenStruct1, OF_READ);
- if (argv[2])
- hDestFile = LZOpenFile(argv[2], &SourceOpenStruct2, OF_CREATE | OF_WRITE);
- else
- {
- TCHAR OriginalName[MAX_PATH];
- GetExpandedName(argv[1], OriginalName);
- hDestFile = LZOpenFile(OriginalName, &SourceOpenStruct2, OF_CREATE |
OF_WRITE);
- }
- ret = LZCopy(hSourceFile, hDestFile);
- LZClose(hSourceFile);
- LZClose(hDestFile);
- LoadString( GetModuleHandle(NULL), IDS_FAILS, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);
- if (ret <= 0) _ftprintf(stderr,szMsg,ret);
- return (ret <= 0);
+ switch (notification)
+ {
+ case SPFILENOTIFY_FILEINCABINET:
+ {
+ LPCSTR targetname = context;
+
+ strcpy( info->FullTargetName, targetname );
+ return FILEOP_DOIT;
+ }
+ default: return NO_ERROR;
+ }
}
+
+static BOOL option_equal(LPCSTR str1, LPCSTR str2)
+{
+ if (str1[0] != '/' && str1[0] != '-')
+ return FALSE;
+ return !lstrcmpA( str1 + 1, str2 );
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ char infile[MAX_PATH], outfile[MAX_PATH], actual_name[MAX_PATH];
+ char outfile_basename[MAX_PATH], *basename_index;
+ UINT comp;
+
+ if (argc < 3)
+ {
+ fprintf( stderr, "Usage:\n" );
+ fprintf( stderr, "\t%s infile outfile\n", argv[0] );
+ fprintf( stderr, "\t%s /r infile\n", argv[0] );
+ return 1;
+ }
+
+ if (argc == 3 && (option_equal(argv[1], "R") ||
option_equal(argv[1], "r")))
+ GetFullPathNameA( argv[2], sizeof(infile), infile, NULL );
+ else
+ GetFullPathNameA( argv[1], sizeof(infile), infile, NULL );
+
+ if (!SetupGetFileCompressionInfoExA( infile, actual_name, sizeof(actual_name), NULL,
NULL, NULL, &comp ))
+ {
+ fprintf( stderr, "%s: can't open input file %s\n", argv[0], infile
);
+ return 1;
+ }
+
+ if (argc == 3 && (option_equal(argv[1], "R") ||
option_equal(argv[1], "r")))
+ {
+ switch (comp)
+ {
+ case FILE_COMPRESSION_MSZIP:
+ {
+ outfile_basename[0] = 0;
+ if (!SetupIterateCabinetA( infile, 0, set_outfile, outfile_basename ))
+ {
+ fprintf( stderr, "%s: can't determine original name\n",
argv[0] );
+ return 1;
+ }
+ GetFullPathNameA( infile, sizeof(outfile), outfile, &basename_index );
+ *basename_index = 0;
+ strcat( outfile, outfile_basename );
+ break;
+ }
+ case FILE_COMPRESSION_WINLZA:
+ {
+ GetExpandedNameA( infile, outfile_basename );
+ break;
+ }
+ default:
+ {
+ fprintf( stderr, "%s: can't determine original\n", argv[0] );
+ return 1;
+ }
+ }
+ }
+ else
+ GetFullPathNameA( argv[2], sizeof(outfile), outfile, NULL );
+
+ if (!lstrcmpiA( infile, outfile ))
+ {
+ fprintf( stderr, "%s: can't expand file to itself\n", argv[0] );
+ return 1;
+ }
+
+ switch (comp)
+ {
+ case FILE_COMPRESSION_MSZIP:
+ {
+ if (!SetupIterateCabinetA( infile, 0, extract_callback, outfile ))
+ {
+ fprintf( stderr, "%s: cabinet extraction failed\n", argv[0] );
+ return 1;
+ }
+ break;
+ }
+ case FILE_COMPRESSION_WINLZA:
+ {
+ INT hin, hout;
+ OFSTRUCT ofin, ofout;
+ LONG error;
+
+ if ((hin = LZOpenFileA( infile, &ofin, OF_READ )) < 0)
+ {
+ fprintf( stderr, "%s: can't open input file %s\n", argv[0],
infile );
+ return 1;
+ }
+ if ((hout = LZOpenFileA( outfile, &ofout, OF_CREATE | OF_WRITE )) < 0)
+ {
+ LZClose( hin );
+ fprintf( stderr, "%s: can't open output file %s\n", argv[0],
outfile );
+ return 1;
+ }
+ error = LZCopy( hin, hout );
+
+ LZClose( hin );
+ LZClose( hout );
+
+ if (error < 0)
+ {
+ fprintf( stderr, "%s: LZCopy failed, error is %ld\n", argv[0],
error );
+ return 1;
+ }
+ break;
+ }
+ default:
+ {
+ if (!CopyFileA( infile, outfile, FALSE ))
+ {
+ fprintf( stderr, "%s: CopyFileA failed\n", argv[0] );
+ return 1;
+ }
+ break;
+ }
+ }
+ return ret;
+}
Modified: trunk/reactos/base/system/expand/expand.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/expand/expand.…
==============================================================================
--- trunk/reactos/base/system/expand/expand.rbuild [iso-8859-1] (original)
+++ trunk/reactos/base/system/expand/expand.rbuild [iso-8859-1] Thu Feb 4 15:40:36 2010
@@ -3,8 +3,8 @@
<module name="expand" type="win32cui"
installbase="system32" installname="expand.exe" >
<include base="ReactOS">include/reactos/wine</include>
<include base="expand">.</include>
- <define name="ANONYMOUSUNIONS" />
<library>lz32</library>
+ <library>setupapi</library>
<library>user32</library>
<file>expand.c</file>
<file>expand.rc</file>
Modified: trunk/reactos/base/system/expand/expand.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/expand/expand.…
==============================================================================
--- trunk/reactos/base/system/expand/expand.rc [iso-8859-1] (original)
+++ trunk/reactos/base/system/expand/expand.rc [iso-8859-1] Thu Feb 4 15:40:36 2010
@@ -3,5 +3,3 @@
#define REACTOS_STR_INTERNAL_NAME "expand\0"
#define REACTOS_STR_ORIGINAL_FILENAME "expand.exe\0"
#include <reactos/version.rc>
-
-#include "rsrc.rc"
Removed: trunk/reactos/base/system/expand/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/expand/resourc…
==============================================================================
--- trunk/reactos/base/system/expand/resource.h [iso-8859-1] (original)
+++ trunk/reactos/base/system/expand/resource.h (removed)
@@ -1,10 +1,0 @@
-#ifndef RESOURCE_H__
-#define RESOURCE_H__
-
-#define RC_STRING_MAX_SIZE 4096
-#define IDS_Copy 100
-#define IDS_FAILS 101
-
-#endif
-
-/* EOF */
Removed: trunk/reactos/base/system/expand/rsrc.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/expand/rsrc.rc…
==============================================================================
--- trunk/reactos/base/system/expand/rsrc.rc [iso-8859-1] (original)
+++ trunk/reactos/base/system/expand/rsrc.rc (removed)
@@ -1,24 +1,0 @@
-#include <windows.h>
-#include "resource.h"
-
-LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
-
-#include "lang/bg-BG.rc"
-#include "lang/cs-CZ.rc"
-#include "lang/de-DE.rc"
-#include "lang/el-GR.rc"
-#include "lang/en-US.rc"
-#include "lang/es-ES.rc"
-#include "lang/fr-FR.rc"
-#include "lang/hu-HU.rc"
-#include "lang/id-ID.rc"
-#include "lang/it-IT.rc"
-#include "lang/ja-JP.rc"
-#include "lang/lt-LT.rc"
-#include "lang/no-NO.rc"
-#include "lang/pl-PL.rc"
-#include "lang/pt-BR.rc"
-#include "lang/ru-RU.rc"
-#include "lang/sv-SE.rc"
-#include "lang/th-TH.rc"
-#include "lang/uk-UA.rc"