From e88572be29de32821960d015988f3ba308f3a4f3 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Sat, 19 Mar 2011 07:59:37 -0400 Subject: [PATCH] Backed out changeset 0c5da403b68e --- config/Makefile.in | 1 - config/config.mk | 2 +- config/nsinstall_win.c | 98 +++-------------------------------- js/src/config/config.mk | 2 +- js/src/config/nsinstall_win.c | 95 +++------------------------------ 5 files changed, 16 insertions(+), 182 deletions(-) diff --git a/config/Makefile.in b/config/Makefile.in index 6b2f0d75e1e..39a41295a03 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -52,7 +52,6 @@ HOST_PROGRAM = nsinstall$(HOST_BIN_SUFFIX) ifeq (WINNT,$(HOST_OS_ARCH)) HOST_CSRCS = nsinstall_win.c -HOST_EXTRA_LIBS = $(call EXPAND_LIBNAME,shlwapi) else HOST_CSRCS = nsinstall.c pathsub.c endif diff --git a/config/config.mk b/config/config.mk index 884fd9271d5..d8c655f9aff 100644 --- a/config/config.mk +++ b/config/config.mk @@ -738,7 +738,7 @@ endif # OS2 endif # NSINSTALL_BIN -ifeq (,$(CROSS_COMPILE)$(filter-out OS2, $(OS_ARCH))) +ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH))) INSTALL = $(NSINSTALL) else ifeq ($(NSDISTMODE),copy) diff --git a/config/nsinstall_win.c b/config/nsinstall_win.c index cdca9cbb7db..d9b723b2c7c 100644 --- a/config/nsinstall_win.c +++ b/config/nsinstall_win.c @@ -11,7 +11,6 @@ #include #include #include -#include #pragma hdrstop /* @@ -27,30 +26,16 @@ typedef BOOL (*sh_FileFcn)( wchar_t *pathName, WIN32_FIND_DATA *fileData, void *arg); -typedef BOOL (*sh_DoFcn)( - wchar_t *srcFileName, - DWORD srcFileAttributes, - wchar_t *dstFileName, - DWORD dstFileAttributes, - int force, - int recursive); -static int shellDo (wchar_t **pArgv, sh_FileFcn, sh_DoFcn); +static int shellCp (wchar_t **pArgv); static int shellNsinstall (wchar_t **pArgv); static int shellMkdir (wchar_t **pArgv); static BOOL sh_EnumerateFiles(const wchar_t *pattern, const wchar_t *where, sh_FileFcn fileFcn, void *arg, int *nFiles); static const char *sh_GetLastErrorMessage(void); -static BOOL sh_DoLnk(wchar_t *srcFileName, DWORD srcFileAttributes, - wchar_t *dstFileName, DWORD dstFileAttributes, - int force, int recursive); static BOOL sh_DoCopy(wchar_t *srcFileName, DWORD srcFileAttributes, wchar_t *dstFileName, DWORD dstFileAttributes, int force, int recursive); -static BOOL sh_LnkFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, - void *cpArg); -static BOOL sh_CpFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, - void *cpArg); #define LONGPATH_PREFIX L"\\\\?\\" #define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0])) @@ -79,13 +64,12 @@ shellNsinstall (wchar_t **pArgv) { int retVal = 0; /* exit status */ int dirOnly = 0; /* 1 if and only if -D is specified */ - int linkFiles = 0; /* 1 iff -R is specified */ wchar_t **pSrc; wchar_t **pDst; /* * Process the command-line options. We ignore the - * options except for -D and -R. Some options, such as -m, + * options except for -D. Some options, such as -m, * are followed by an argument. We need to skip the * argument too. */ @@ -94,8 +78,6 @@ shellNsinstall (wchar_t **pArgv) if ( c == 'D' ) { dirOnly = 1; - } else if ( c == 'R' ) { - linkFiles = 1; } else if ( c == 'm' ) { pArgv++; /* skip the next argument */ } @@ -129,13 +111,8 @@ shellNsinstall (wchar_t **pArgv) retVal = shellMkdir ( pDst ); if ( retVal ) return retVal; - if ( !dirOnly ) { - if ( linkFiles) { - retVal = shellDo ( pSrc, sh_LnkFileCmd, sh_DoLnk ); - } else { - retVal = shellDo ( pSrc, sh_CpFileCmd, sh_DoCopy ); - } - } + if ( !dirOnly ) + retVal = shellCp ( pSrc ); return retVal; } @@ -248,53 +225,6 @@ sh_RecordFileData(wchar_t *pathName, WIN32_FIND_DATA *findData, void *arg) return TRUE; } -static BOOL -sh_DoLnk(wchar_t *srcFileName, - DWORD srcFileAttributes, - wchar_t *dstFileName, - DWORD dstFileAttributes, - int force, - int recursive -) -{ - BOOL willDeleteFile = (dstFileAttributes != 0xFFFFFFFF) ? TRUE : FALSE; - - if (srcFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - fprintf(stderr, "nsinstall: %ls is a directory\n", - srcFileName); - return FALSE; - } else { - DWORD r; - wchar_t longSrc[1004] = LONGPATH_PREFIX; - wchar_t longDst[1004] = LONGPATH_PREFIX; - r = GetFullPathName(srcFileName, 1000, longSrc + STR_LEN(LONGPATH_PREFIX), NULL); - if (!r) { - fprintf(stderr, "nsinstall: couldn't get full path of %ls: %s\n", - srcFileName, sh_GetLastErrorMessage()); - return FALSE; - } - r = GetFullPathName(dstFileName, 1000, longDst + ARRAY_LEN(LONGPATH_PREFIX) - 1, NULL); - if (!r) { - fprintf(stderr, "nsinstall: couldn't get full path of %ls: %s\n", - dstFileName, sh_GetLastErrorMessage()); - return FALSE; - } - - if (willDeleteFile) { - DeleteFile(dstFileName); - } - - if (!CreateHardLink(longDst, longSrc, NULL)) { - fprintf(stderr, "nsinstall: warning! cannot link %ls to %ls: %s\n", - srcFileName, dstFileName, sh_GetLastErrorMessage()); - return sh_DoCopy(srcFileName, srcFileAttributes, - dstFileName, dstFileAttributes, - force, recursive); - } - } - return TRUE; -} - static BOOL sh_DoCopy(wchar_t *srcFileName, DWORD srcFileAttributes, @@ -333,8 +263,6 @@ sh_DoCopy(wchar_t *srcFileName, } if (!CopyFile(longSrc, longDst, FALSE)) { - if (!wcscmp(PathFindExtension(longSrc), L".chk")) - return TRUE; // Incredibly ugly hack to work around Bug 539689 fprintf(stderr, "nsinstall: cannot copy %ls to %ls: %s\n", srcFileName, dstFileName, sh_GetLastErrorMessage()); return FALSE; @@ -388,20 +316,8 @@ sh_CpFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, void *cpArg) arg->force, arg->recursive); } -static BOOL -sh_LnkFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, void *cpArg) -{ - BOOL retVal = TRUE; - struct sh_CpCmdArg *arg = (struct sh_CpCmdArg *) cpArg; - - wcscpy(arg->dstFileNameMarker, findData->cFileName); - return sh_DoLnk(pathName, findData->dwFileAttributes, - arg->dstFileName, GetFileAttributes(arg->dstFileName), - arg->force, arg->recursive); -} - static int -shellDo (wchar_t **pArgv, sh_FileFcn doFooCmd, sh_DoFcn doFoo) +shellCp (wchar_t **pArgv) { int retVal = 0; wchar_t **pSrc; @@ -537,7 +453,7 @@ shellDo (wchar_t **pArgv, sh_FileFcn doFooCmd, sh_DoFcn doFoo) retVal = 3; } else { assert(n == 1); - if ((*doFoo)(srcData.pathName, srcData.dwFileAttributes, + if (sh_DoCopy(srcData.pathName, srcData.dwFileAttributes, dstData.pathName, dstData.dwFileAttributes, arg.force, arg.recursive) == FALSE) { retVal = 3; @@ -550,7 +466,7 @@ shellDo (wchar_t **pArgv, sh_FileFcn doFooCmd, sh_DoFcn doFoo) BOOL rv; changeForwardSlashesToBackSlashes(*pSrc); - rv = sh_EnumerateFiles(*pSrc, *pSrc, doFooCmd, &arg, &n); + rv = sh_EnumerateFiles(*pSrc, *pSrc, sh_CpFileCmd, &arg, &n); if (rv == FALSE) { retVal = 3; } else { diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 884fd9271d5..d8c655f9aff 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -738,7 +738,7 @@ endif # OS2 endif # NSINSTALL_BIN -ifeq (,$(CROSS_COMPILE)$(filter-out OS2, $(OS_ARCH))) +ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH))) INSTALL = $(NSINSTALL) else ifeq ($(NSDISTMODE),copy) diff --git a/js/src/config/nsinstall_win.c b/js/src/config/nsinstall_win.c index ccc9dc94f2c..d9b723b2c7c 100644 --- a/js/src/config/nsinstall_win.c +++ b/js/src/config/nsinstall_win.c @@ -26,30 +26,16 @@ typedef BOOL (*sh_FileFcn)( wchar_t *pathName, WIN32_FIND_DATA *fileData, void *arg); -typedef BOOL (*sh_DoFcn)( - wchar_t *srcFileName, - DWORD srcFileAttributes, - wchar_t *dstFileName, - DWORD dstFileAttributes, - int force, - int recursive); -static int shellDo (wchar_t **pArgv, sh_FileFcn, sh_DoFcn); +static int shellCp (wchar_t **pArgv); static int shellNsinstall (wchar_t **pArgv); static int shellMkdir (wchar_t **pArgv); static BOOL sh_EnumerateFiles(const wchar_t *pattern, const wchar_t *where, sh_FileFcn fileFcn, void *arg, int *nFiles); static const char *sh_GetLastErrorMessage(void); -static BOOL sh_DoLnk(wchar_t *srcFileName, DWORD srcFileAttributes, - wchar_t *dstFileName, DWORD dstFileAttributes, - int force, int recursive); static BOOL sh_DoCopy(wchar_t *srcFileName, DWORD srcFileAttributes, wchar_t *dstFileName, DWORD dstFileAttributes, int force, int recursive); -static BOOL sh_LnkFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, - void *cpArg); -static BOOL sh_CpFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, - void *cpArg); #define LONGPATH_PREFIX L"\\\\?\\" #define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0])) @@ -78,13 +64,12 @@ shellNsinstall (wchar_t **pArgv) { int retVal = 0; /* exit status */ int dirOnly = 0; /* 1 if and only if -D is specified */ - int linkFiles = 0; /* 1 iff -R is specified */ wchar_t **pSrc; wchar_t **pDst; /* * Process the command-line options. We ignore the - * options except for -D and -R. Some options, such as -m, + * options except for -D. Some options, such as -m, * are followed by an argument. We need to skip the * argument too. */ @@ -93,8 +78,6 @@ shellNsinstall (wchar_t **pArgv) if ( c == 'D' ) { dirOnly = 1; - } else if ( c == 'R' ) { - linkFiles = 1; } else if ( c == 'm' ) { pArgv++; /* skip the next argument */ } @@ -128,13 +111,8 @@ shellNsinstall (wchar_t **pArgv) retVal = shellMkdir ( pDst ); if ( retVal ) return retVal; - if ( !dirOnly ) { - if ( linkFiles) { - retVal = shellDo ( pSrc, sh_LnkFileCmd, sh_DoLnk ); - } else { - retVal = shellDo ( pSrc, sh_CpFileCmd, sh_DoCopy ); - } - } + if ( !dirOnly ) + retVal = shellCp ( pSrc ); return retVal; } @@ -247,53 +225,6 @@ sh_RecordFileData(wchar_t *pathName, WIN32_FIND_DATA *findData, void *arg) return TRUE; } -static BOOL -sh_DoLnk(wchar_t *srcFileName, - DWORD srcFileAttributes, - wchar_t *dstFileName, - DWORD dstFileAttributes, - int force, - int recursive -) -{ - BOOL willDeleteFile = (dstFileAttributes != 0xFFFFFFFF) ? TRUE : FALSE; - - if (srcFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - fprintf(stderr, "nsinstall: %ls is a directory\n", - srcFileName); - return FALSE; - } else { - DWORD r; - wchar_t longSrc[1004] = LONGPATH_PREFIX; - wchar_t longDst[1004] = LONGPATH_PREFIX; - r = GetFullPathName(srcFileName, 1000, longSrc + STR_LEN(LONGPATH_PREFIX), NULL); - if (!r) { - fprintf(stderr, "nsinstall: couldn't get full path of %ls: %s\n", - srcFileName, sh_GetLastErrorMessage()); - return FALSE; - } - r = GetFullPathName(dstFileName, 1000, longDst + ARRAY_LEN(LONGPATH_PREFIX) - 1, NULL); - if (!r) { - fprintf(stderr, "nsinstall: couldn't get full path of %ls: %s\n", - dstFileName, sh_GetLastErrorMessage()); - return FALSE; - } - - if (willDeleteFile) { - DeleteFile(dstFileName); - } - - if (!CreateHardLink(longDst, longSrc, NULL)) { - fprintf(stderr, "nsinstall: warning! cannot link %ls to %ls: %s\n", - srcFileName, dstFileName, sh_GetLastErrorMessage()); - return sh_DoCopy(srcFileName, srcFileAttributes, - dstFileName, dstFileAttributes, - force, recursive); - } - } - return TRUE; -} - static BOOL sh_DoCopy(wchar_t *srcFileName, DWORD srcFileAttributes, @@ -385,20 +316,8 @@ sh_CpFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, void *cpArg) arg->force, arg->recursive); } -static BOOL -sh_LnkFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, void *cpArg) -{ - BOOL retVal = TRUE; - struct sh_CpCmdArg *arg = (struct sh_CpCmdArg *) cpArg; - - wcscpy(arg->dstFileNameMarker, findData->cFileName); - return sh_DoLnk(pathName, findData->dwFileAttributes, - arg->dstFileName, GetFileAttributes(arg->dstFileName), - arg->force, arg->recursive); -} - static int -shellDo (wchar_t **pArgv, sh_FileFcn doFooCmd, sh_DoFcn doFoo) +shellCp (wchar_t **pArgv) { int retVal = 0; wchar_t **pSrc; @@ -534,7 +453,7 @@ shellDo (wchar_t **pArgv, sh_FileFcn doFooCmd, sh_DoFcn doFoo) retVal = 3; } else { assert(n == 1); - if ((*doFoo)(srcData.pathName, srcData.dwFileAttributes, + if (sh_DoCopy(srcData.pathName, srcData.dwFileAttributes, dstData.pathName, dstData.dwFileAttributes, arg.force, arg.recursive) == FALSE) { retVal = 3; @@ -547,7 +466,7 @@ shellDo (wchar_t **pArgv, sh_FileFcn doFooCmd, sh_DoFcn doFoo) BOOL rv; changeForwardSlashesToBackSlashes(*pSrc); - rv = sh_EnumerateFiles(*pSrc, *pSrc, doFooCmd, &arg, &n); + rv = sh_EnumerateFiles(*pSrc, *pSrc, sh_CpFileCmd, &arg, &n); if (rv == FALSE) { retVal = 3; } else {