fix potential memory problems in makecopy, turn NT symlinking on

for performance, clobber speedups
This commit is contained in:
dveditz%netscape.com 1999-08-06 13:45:09 +00:00
parent 56a02adde8
commit 1cd25c1445
4 changed files with 57 additions and 34 deletions

View File

@ -319,10 +319,14 @@ CFLAGS = $(CFLAGS) -Gh
#enable builds on any drive if defined.
MOZ_SRC=y:
!endif
MAKE_INSTALL=$(QUIET)$(DEPTH)\config\makecopy.exe
MAKE_INSTALL=$(QUIET)$(DEPTH)\config\makecopy.exe -s
MAKE_MANGLE=$(DEPTH)\config\mangle.exe
MAKE_UNMANGLE=if exist unmangle.bat call unmangle.bat
!if defined(MOZ_PURIFY)
# add #line directive to header files for purify
MKCPYFLAGS= -i
!endif
#//------------------------------------------------------------------------

View File

@ -144,21 +144,26 @@ int ReportError(const char* msg)
BOOL hardSymLink(LPCSTR src, LPCSTR dest)
{
WCHAR FileLink[ MAX_PATH + 1 ];
WCHAR FileSource[ MAX_PATH + 1 ];
WCHAR FileDest[ MAX_PATH + 1 ];
LPWSTR FilePart;
WIN32_STREAM_ID StreamId;
DWORD dwBytesWritten;
DWORD cbPathLen;
BOOL bSuccess;
// Convert src and dest to Unicode
DWORD cbPathLen = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
LPWSTR FileSource = new WCHAR[cbPathLen+1];
MultiByteToWideChar(CP_ACP, 0, src, -1, FileSource, cbPathLen);
if (!MultiByteToWideChar(CP_ACP, 0, src, -1, FileSource, MAX_PATH)) {
ReportError("Convert to WCHAR (source)");
return FALSE;
}
cbPathLen = MultiByteToWideChar(CP_ACP, 0, dest, -1, NULL, 0);
LPWSTR FileDest = new WCHAR[cbPathLen+1];
MultiByteToWideChar(CP_ACP, 0, dest, -1, FileDest, cbPathLen);
if (!MultiByteToWideChar(CP_ACP, 0, dest, -1, FileDest, MAX_PATH)) {
ReportError("Convert to WCHAR (destination)");
return FALSE;
}
//
// open existing file that we link to
@ -266,15 +271,12 @@ BOOL hardSymLink(LPCSTR src, LPCSTR dest)
return FALSE;
}
delete FileSource;
delete FileDest;
return TRUE;
}
int CopyIfNecessary(const char *oldFile, const char *newFile)
{
LPTSTR fullPathName = NULL;
char fullPathName[ MAX_PATH + 1 ];
LPTSTR filenamePart = NULL;
char buffer[8192];
@ -301,10 +303,7 @@ int CopyIfNecessary(const char *oldFile, const char *newFile)
// find out required size
DWORD bufSize = GetFullPathName(oldFile, 0, fullPathName, &filenamePart);
fullPathName = new char[bufSize];
GetFullPathName(oldFile, bufSize, fullPathName, &filenamePart);
GetFullPathName(oldFile, MAX_PATH, fullPathName, &filenamePart);
// If we need to insert #line, the copying is a bit involved.
if (insertHashLine == TRUE) {
@ -366,17 +365,15 @@ int CopyIfNecessary(const char *oldFile, const char *newFile)
char *c = strchr(fullPathName, '\\');
if (c != NULL) {
LPTSTR fileSystemName;
TCHAR fileSystemName[50];
strncpy(rootPathName, fullPathName, (c - fullPathName) + 1);
fileSystemName = new TCHAR[50];
if (!GetVolumeInformation(rootPathName, NULL, 0, NULL, NULL, NULL, fileSystemName, sizeof(rootPathName))) {
return ReportError("GetVolumeInformation");
}
isNTFS = (strcmp(fileSystemName, "NTFS") == 0);
delete fileSystemName;
}
}
@ -396,16 +393,16 @@ int CopyIfNecessary(const char *oldFile, const char *newFile)
}
}
delete fullPathName;
return 0;
}
void Usage(void)
{
fprintf(stderr, "makecopy: [-is] <file1> [file2 ... fileN] <dir-path>\n");
fprintf(stderr, " -i -- add #line directive\n");
fprintf(stderr, " -s -- use symlinks on NT when possible\n");
fprintf(stderr, "makecopy: [-cisx] <file1> [file2 ... fileN] <dir-path>\n");
fprintf(stderr, " -c copy [default], cancels -s\n");
fprintf(stderr, " -i add #line directive\n");
fprintf(stderr, " -s use symlinks on NT when possible\n");
fprintf(stderr, " -x cancel -i\n");
}
@ -428,11 +425,20 @@ int main( int argc, char *argv[] )
for ( ; *argv[i] == '-' ; ++i) {
char *opt = argv[i]+1;
for ( ; *opt; ++opt) {
if ( *opt == 'i' )
switch (*opt) {
case 'c':
trySymlink = FALSE;
break;
case 'i':
insertHashLine = TRUE;
else if ( *opt == 's' )
break;
case 's':
trySymlink = TRUE;
else {
break;
case 'x':
insertHashLine = FALSE;
break;
default:
Usage();
return 2;
}

Binary file not shown.

View File

@ -590,17 +590,23 @@ export:: $(JMC_STUBS) $(OBJDIR) $(JMC_OBJS)
export::
@echo +++ make: exporting headers
$(MAKE_INSTALL:/=\) -i $(EXPORTS) $(PUBLIC)
$(MAKE_INSTALL:/=\) $(MKCPYFLAGS) $(EXPORTS) $(PUBLIC)
clobber::
#// don't delete exported stuff on a local clobber, use clobber_all
#clobber::
#!if exist($(PUBLIC))
# @cd $(PUBLIC)
# -$(RM) $(EXPORTS)
# @cd $(MAKEDIR)
#!endif # $(PUBLIC) exists
clobber_all::
!if exist($(PUBLIC))
@cd $(PUBLIC)
-$(RM) $(EXPORTS)
@cd $(MAKEDIR)
!endif # $(PUBLIC) exists
clobber_all:: clobber
!endif # EXPORTS
#//------------------------------------------------------------------------
@ -616,10 +622,14 @@ clean:: $(DIRS)
-$(RM) $(OBJS) $(NOSUCHFILE) NUL 2> NUL
clobber:: $(DIRS)
!if defined(GARBAGE) || exist($(OBJDIR))
-$(RM_R) $(GARBAGE) $(OBJDIR) 2> NUL
!endif
clobber_all:: $(DIRS)
-$(RM_R) *.OBJ $(TARGETS) $(GARBAGE) $(OBJDIR) 2> NUL
!if defined(GARBAGE) || "$(TARGETS)" != " " || exist($(OBJDIR))
-$(RM_R) $(TARGETS) $(GARBAGE) $(OBJDIR) 2> NUL
!endif
!if "$(MOZ_BITS)"=="32"
CFLAGS = $(CFLAGS) -DNO_JNI_STUBS
@ -699,6 +709,10 @@ install:: $(XPIDL_GEN_DIR) $(TYPELIB)
!endif
clobber::
-$(RM_R) $(XPIDL_GEN_DIR) 2> NUL
clobber_all::
-$(RM_R) $(XPIDL_GEN_DIR) 2> NUL
!if exist($(PUBLIC))
@cd $(PUBLIC)
-$(RM) $(XPIDLSRCS:.idl=.h)
@ -709,10 +723,9 @@ clobber::
-$(RM) $(XPIDLSRCS)
@cd $(MAKEDIR)
!endif
-$(RM_R) $(XPIDL_GEN_DIR) 2> NUL
clobber_all:: clobber
!if exist($(DIST)\bin\components)
-$(RM) $(DIST)\bin\components\$(XPIDL_MODULE).xpt
!endif
!endif
!endif