#include "pal/palinternal.h"
#include "pal/dbgmsg.h"
#include "pal/file.h"
+#include "pal/stackstring.hpp"
#if HAVE_ALLOCA_H
#include <alloca.h>
{
DWORD dwLastError = 0;
BOOL bRet = FALSE;
- char mb_dir[MAX_LONGPATH];
-
+ PathCharString mb_dirPathString;
+ size_t length;
+ char * mb_dir;
+
PERF_ENTRY(RemoveDirectoryA);
ENTRY("RemoveDirectoryA(lpPathName=%p (%s))\n",
lpPathName,
goto done;
}
- mb_dir[MAX_LONGPATH - 1] = '\0';
- if (strncpy_s (mb_dir, sizeof(mb_dir), lpPathName, MAX_LONGPATH) != SAFECRT_SUCCESS)
+ length = strlen(lpPathName);
+ mb_dir = mb_dirPathString.OpenStringBuffer(length);
+ if (strncpy_s (mb_dir, sizeof(char) * (length+1), lpPathName, MAX_LONGPATH) != SAFECRT_SUCCESS)
{
+ mb_dirPathString.CloseBuffer(length);
WARN("mb_dir is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH);
dwLastError = ERROR_FILENAME_EXCED_RANGE;
goto done;
}
+ mb_dirPathString.CloseBuffer(length);
bRet = RemoveDirectoryHelper (mb_dir, &dwLastError);
done:
RemoveDirectoryW(
IN LPCWSTR lpPathName)
{
- char mb_dir[MAX_LONGPATH];
+ PathCharString mb_dirPathString;
int mb_size;
DWORD dwLastError = 0;
BOOL bRet = FALSE;
+ size_t length;
+ char * mb_dir;
PERF_ENTRY(RemoveDirectoryW);
ENTRY("RemoveDirectoryW(lpPathName=%p (%S))\n",
dwLastError = ERROR_PATH_NOT_FOUND;
goto done;
}
-
- mb_size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, mb_dir, MAX_LONGPATH,
+
+ length = (PAL_wcslen(lpPathName)+1) * 3;
+ mb_dir = mb_dirPathString.OpenStringBuffer(length);
+ mb_size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, mb_dir, length,
NULL, NULL );
+ mb_dirPathString.CloseBuffer(mb_size);
+
if( mb_size == 0 )
{
dwLastError = GetLastError();
{
BOOL bRet;
DWORD dwLastError = 0;
- char dir[MAX_LONGPATH];
+ PathCharString dirPathString;
int size;
-
+ size_t length;
+ char * dir;
+
PERF_ENTRY(SetCurrentDirectoryW);
ENTRY("SetCurrentDirectoryW(lpPathName=%p (%S))\n",
lpPathName?lpPathName:W16_NULLSTRING,
goto done;
}
- size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, dir, MAX_LONGPATH,
+ length = (PAL_wcslen(lpPathName)+1) * 3;
+ dir = dirPathString.OpenStringBuffer(length);
+ size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, dir, length,
NULL, NULL );
+ dirPathString.CloseBuffer(size);
+
if( size == 0 )
{
dwLastError = GetLastError();
#include "pal/palinternal.h"
#include "pal/dbgmsg.h"
#include "pal/file.h"
+#include "pal/stackstring.hpp"
#include <sys/param.h>
#if !defined(_AIX)
pal_statfs fsInfoBuffer;
INT statfsRetVal = 0;
DWORD dwLastError = NO_ERROR;
- CHAR DirNameBuffer[ MAX_LONGPATH ];
+ PathCharString dirNameBufferPathString;
+ size_t length;
+ char * dirNameBuffer;
+ int size;
PERF_ENTRY(GetDiskFreeSpaceW);
ENTRY( "GetDiskFreeSpaceW( lpDirectoryName=%p (%S), lpSectorsPerCluster=%p,"
if ( lpDirectoryName )
{
- if ( WideCharToMultiByte( CP_ACP, 0, lpDirectoryName, -1,
- DirNameBuffer,MAX_LONGPATH, 0, 0 ) != 0 )
+ length = (PAL_wcslen(lpDirectoryName)+1) * 3;
+ dirNameBuffer = dirNameBufferPathString.OpenStringBuffer(length);
+ size = WideCharToMultiByte( CP_ACP, 0, lpDirectoryName, -1,
+ dirNameBuffer,length, 0, 0 );
+ dirNameBufferPathString.CloseBuffer(size);
+ if ( size != 0 )
{
- FILEDosToUnixPathA( DirNameBuffer );
- statfsRetVal = statfs( DirNameBuffer, &fsInfoBuffer );
+ FILEDosToUnixPathA( dirNameBuffer );
+ statfsRetVal = statfs( dirNameBuffer, &fsInfoBuffer );
}
else
{
{
if ( errno == ENOTDIR || errno == ENOENT )
{
- FILEGetProperNotFoundError( DirNameBuffer, &dwLastError );
+ FILEGetProperNotFoundError( dirNameBuffer, &dwLastError );
goto exit;
}
dwLastError = FILEGetLastErrorFromErrno();
#include "pal/file.hpp"
#include "shmfilelockmgr.hpp"
#include "pal/malloc.hpp"
+#include "pal/stackstring.hpp"
#include "pal/palinternal.h"
#include "pal/dbgmsg.h"
SET_DEFAULT_DEBUG_CHANNEL(FILE);
+int MaxWCharToAcpLengthRatio = 3;
+
PAL_ERROR
InternalSetFilePointerForUnixFd(
int iUnixFd,
{
CPalThread *pThread;
PAL_ERROR palError = NO_ERROR;
- char name[MAX_LONGPATH];
- int size;
+ PathCharString namePathString;
+ char * name;
+ int size;
+ int length = 0;
HANDLE hRet = INVALID_HANDLE_VALUE;
PERF_ENTRY(CreateFileW);
pThread = InternalGetCurrentThread();
- size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH,
+ if (lpFileName != NULL)
+ {
+ length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthRatio;
+ }
+
+ name = namePathString.OpenStringBuffer(length);
+ size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length,
NULL, NULL );
+ namePathString.CloseBuffer(size);
+
if( size == 0 )
{
DWORD dwLastError = GetLastError();
IN BOOL bFailIfExists)
{
CPalThread *pThread;
- char source[MAX_LONGPATH];
- char dest[MAX_LONGPATH];
- int src_size,dest_size;
- BOOL bRet = FALSE;
+ PathCharString sourcePathString;
+ PathCharString destPathString;
+ char * source;
+ char * dest;
+ int src_size, dest_size, length = 0;
+ BOOL bRet = FALSE;
PERF_ENTRY(CopyFileW);
ENTRY("CopyFileW(lpExistingFileName=%p (%S), lpNewFileName=%p (%S), bFailIfExists=%d)\n",
lpNewFileName?lpNewFileName:W16_NULLSTRING, bFailIfExists);
pThread = InternalGetCurrentThread();
- src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, MAX_LONGPATH,
+ if (lpExistingFileName != NULL)
+ {
+ length = (PAL_wcslen(lpExistingFileName)+1) * MaxWCharToAcpLengthRatio;
+ }
+
+ source = sourcePathString.OpenStringBuffer(length);
+ src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, length,
NULL, NULL );
+ sourcePathString.CloseBuffer(src_size);
+
if( src_size == 0 )
{
DWORD dwLastError = GetLastError();
goto done;
}
- dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, MAX_LONGPATH,
+ length = 0;
+ if (lpNewFileName != NULL)
+ {
+ length = (PAL_wcslen(lpNewFileName)+1) * MaxWCharToAcpLengthRatio;
+ }
+
+ dest = destPathString.OpenStringBuffer(length);
+ dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, length,
NULL, NULL );
+ destPathString.CloseBuffer(dest_size);
+
if( dest_size == 0 )
{
DWORD dwLastError = GetLastError();
int result;
BOOL bRet = FALSE;
DWORD dwLastError = 0;
- char lpUnixFileName[MAX_LONGPATH];
+ char * lpUnixFileName;
+ int length;
+ PathCharString lpUnixFileNamePS;
LPSTR lpFullUnixFileName = NULL;
DWORD cchFullUnixFileName = MAX_LONGPATH+1;// InternalCanonicalizeRealPath requires this to be atleast PATH_MAX
ENTRY("DeleteFileA(lpFileName=%p (%s))\n", lpFileName?lpFileName:"NULL", lpFileName?lpFileName:"NULL");
pThread = InternalGetCurrentThread();
- if (strlen(lpFileName) >= MAX_LONGPATH)
+ length = strlen(lpFileName);
+ if (length >= MAX_LONGPATH)
{
WARN("lpFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH);
pThread->SetLastError(ERROR_FILENAME_EXCED_RANGE);
goto done;
}
- strcpy_s( lpUnixFileName, sizeof(lpUnixFileName), lpFileName);
+ lpUnixFileName = lpUnixFileNamePS.OpenStringBuffer(length);
+ strcpy_s( lpUnixFileName, lpUnixFileNamePS.GetSizeOf(), lpFileName);
+ lpUnixFileNamePS.CloseBuffer(length);
FILEDosToUnixPathA( lpUnixFileName );
{
CPalThread *pThread;
int size;
- char name[MAX_LONGPATH];
+ PathCharString namePS;
+ char * name;
+ int length = 0;
BOOL bRet = FALSE;
PERF_ENTRY(DeleteFileW);
lpFileName?lpFileName:W16_NULLSTRING);
pThread = InternalGetCurrentThread();
- size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH,
+
+ if (lpFileName != NULL)
+ {
+ length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthRatio;
+ }
+
+ name = namePS.OpenStringBuffer(length);
+ size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length,
NULL, NULL );
+ namePS.CloseBuffer(size);
+
if( size == 0 )
{
DWORD dwLastError = GetLastError();
{
CPalThread *pThread;
int result;
- char source[MAX_LONGPATH];
- char dest[MAX_LONGPATH];
+ int length = 0;
+ PathCharString sourcePS;
+ PathCharString destPS;
+ char * source;
+ char * dest;
BOOL bRet = TRUE;
DWORD dwLastError = 0;
goto done;
}
- if (strlen(lpExistingFileName) >= MAX_LONGPATH)
+ length = strlen(lpExistingFileName);
+ if (length >= MAX_LONGPATH)
{
WARN("lpExistingFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH);
pThread->SetLastError(ERROR_FILENAME_EXCED_RANGE);
goto done;
}
- strcpy_s( source, sizeof(source), lpExistingFileName);
-
+ source = sourcePS.OpenStringBuffer(length);
+ strcpy_s( source, sourcePS.GetSizeOf(), lpExistingFileName);
+ sourcePS.CloseBuffer(length);
+
FILEDosToUnixPathA( source );
- if (strlen(lpNewFileName) >= MAX_LONGPATH)
+ length = strlen(lpNewFileName);
+ if (length >= MAX_LONGPATH)
{
WARN("lpNewFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH);
pThread->SetLastError(ERROR_FILENAME_EXCED_RANGE);
goto done;
}
- strcpy_s( dest, sizeof(dest), lpNewFileName);
-
+ dest = destPS.OpenStringBuffer(length);
+ strcpy_s( dest, destPS.GetSizeOf(), lpNewFileName);
+ destPS.CloseBuffer(length);
+
FILEDosToUnixPathA( dest );
if ( !FILEGetFileNameFromSymLink(source))
IN DWORD dwFlags)
{
CPalThread *pThread;
- char source[MAX_LONGPATH];
- char dest[MAX_LONGPATH];
+ PathCharString sourcePS;
+ PathCharString destPS;
+ char * source;
+ char * dest;
+ int length = 0;
int src_size,dest_size;
BOOL bRet = FALSE;
lpNewFileName?lpNewFileName:W16_NULLSTRING, dwFlags);
pThread = InternalGetCurrentThread();
- src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, MAX_LONGPATH,
+
+ if (lpExistingFileName != NULL)
+ {
+ length = (PAL_wcslen(lpExistingFileName)+1) * MaxWCharToAcpLengthRatio;
+ }
+
+ source = sourcePS.OpenStringBuffer(length);
+ src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, length,
NULL, NULL );
+ sourcePS.CloseBuffer(src_size);
if( src_size == 0 )
{
DWORD dwLastError = GetLastError();
goto done;
}
- dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, MAX_LONGPATH,
+ length = 0;
+ if (lpNewFileName != NULL)
+ {
+ length = (PAL_wcslen(lpNewFileName)+1) * MaxWCharToAcpLengthRatio;
+ }
+
+ dest = destPS.OpenStringBuffer(length);
+ dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, length,
NULL, NULL );
+ destPS.CloseBuffer(dest_size);
+
if( dest_size == 0 )
{
DWORD dwLastError = GetLastError();
struct stat stat_data;
DWORD dwAttr = 0;
DWORD dwLastError = 0;
- CHAR UnixFileName[MAX_LONGPATH + 1];
+ CHAR * UnixFileName;
+ int length = 0;
+ PathCharString UnixFileNamePS;
PERF_ENTRY(GetFileAttributesA);
ENTRY("GetFileAttributesA(lpFileName=%p (%s))\n", lpFileName?lpFileName:"NULL", lpFileName?lpFileName:"NULL");
goto done;
}
- if (strlen(lpFileName) >= MAX_LONGPATH)
+ length = strlen(lpFileName);
+ if (length >= MAX_LONGPATH)
{
WARN("lpFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH);
dwLastError = ERROR_FILENAME_EXCED_RANGE;
goto done;
}
- strcpy_s( UnixFileName, sizeof(UnixFileName), lpFileName );
-
+ UnixFileName = UnixFileNamePS.OpenStringBuffer(length);
+ strcpy_s( UnixFileName, UnixFileNamePS.GetSizeOf(), lpFileName );
+ UnixFileNamePS.CloseBuffer(length);
+
FILEDosToUnixPathA( UnixFileName );
if ( stat(UnixFileName, &stat_data) != 0 )
{
CPalThread *pThread;
int size;
- char filename[MAX_LONGPATH];
+ PathCharString filenamePS;
+ int length = 0;
+ char * filename;
DWORD dwRet = (DWORD) -1;
PERF_ENTRY(GetFileAttributesW);
goto done;
}
- size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, filename, MAX_LONGPATH,
+ length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthRatio;
+ filename = filenamePS.OpenStringBuffer(length);
+ size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, filename, length,
NULL, NULL );
+ filenamePS.CloseBuffer(size);
+
if( size == 0 )
{
DWORD dwLastError = GetLastError();
struct stat stat_data;
- char name[MAX_LONGPATH];
+ char * name;
+ PathCharString namePS;
+ int length = 0;
int size;
PERF_ENTRY(GetFileAttributesExW);
goto done;
}
- size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH,
+ length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthRatio;
+ name = namePS.OpenStringBuffer(length);
+ size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length,
NULL, NULL );
+ namePS.CloseBuffer(size);
+
if( size == 0 )
{
dwLastError = GetLastError();
IN DWORD dwFileAttributes)
{
CPalThread *pThread;
- char name[MAX_LONGPATH];
+ char * name;
+ PathCharString namePS;
+ int length = 0;
int size;
DWORD dwLastError = 0;
goto done;
}
- size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH,
+ length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthRatio;
+ name = namePS.OpenStringBuffer(length);
+ size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length,
NULL, NULL );
+ namePS.CloseBuffer(size);
+
if( size == 0 )
{
dwLastError = GetLastError();
OUT LPSTR lpTempFileName)
{
CPalThread *pThread;
- CHAR full_name[ MAX_LONGPATH + 1 ];
- CHAR file_template[ MAX_LONGPATH + 1 ];
+ CHAR * full_name;
+ PathCharString full_namePS;
+ int length;
+ CHAR * file_template;
+ PathCharString file_templatePS;
CHAR chLastPathNameChar;
HANDLE hTempFile;
goto done;
}
+ length = strlen(lpPathName) + MAX_SEEDSIZE + MAX_PREFIX + 10;
+ file_template = file_templatePS.OpenStringBuffer(length);
*file_template = '\0';
- strcat_s( file_template, sizeof(file_template), lpPathName );
+ strcat_s( file_template, file_templatePS.GetSizeOf(), lpPathName );
+ file_templatePS.CloseBuffer(length);
chLastPathNameChar = file_template[strlen(file_template)-1];
if (chLastPathNameChar != '\\' && chLastPathNameChar != '/')
{
- strcat_s( file_template, sizeof(file_template), "\\" );
+ strcat_s( file_template, file_templatePS.GetSizeOf(), "\\" );
}
if ( lpPrefixString )
{
- strncat_s( file_template, sizeof(file_template), lpPrefixString, MAX_PREFIX );
+ strncat_s( file_template, file_templatePS.GetSizeOf(), lpPrefixString, MAX_PREFIX );
}
FILEDosToUnixPathA( file_template );
- strncat_s( file_template, sizeof(file_template), "%.4x.TMP", MAX_SEEDSIZE );
+ strncat_s( file_template, file_templatePS.GetSizeOf(), "%.4x.TMP", MAX_SEEDSIZE );
/* Create the file. */
dwError = GetLastError();
pThread->SetLastError( NOERROR );
- sprintf_s( full_name, sizeof(full_name), file_template, (0 == uUnique) ? uUniqueSeed : uUnique);
+ length = strlen(file_template) + MAX_SEEDSIZE + MAX_PREFIX;
+ full_name = full_namePS.OpenStringBuffer(length);
+ sprintf_s( full_name, full_namePS.GetSizeOf(), file_template, (0 == uUnique) ? uUniqueSeed : uUnique);
+ full_namePS.CloseBuffer(length);
hTempFile = CreateFileA( full_name, GENERIC_WRITE,
FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL );
ENSURE_UNIQUE_NOT_ZERO;
pThread->SetLastError( NOERROR );
- sprintf_s( full_name, sizeof(full_name), file_template, uUniqueSeed );
+ sprintf_s( full_name, full_namePS.GetSizeOf(), file_template, uUniqueSeed );
hTempFile = CreateFileA( full_name, GENERIC_WRITE,
FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL );
uLoopCounter++;
CPalThread *pThread;
INT path_size = 0;
INT prefix_size = 0;
- CHAR full_name[ MAX_LONGPATH + 1 ];
- CHAR prefix_string[ MAX_LONGPATH + 1 ];
- CHAR tempfile_name[ MAX_PATH_FNAME + 1 ];
+ CHAR * full_name;
+ CHAR * prefix_string;
+ CHAR * tempfile_name;
+ PathCharString full_namePS, prefix_stringPS;
+ INT length = 0;
UINT uRet;
PERF_ENTRY(GetTempFileNameW);
goto done;
}
+ length = (PAL_wcslen(lpPathName)+1) * MaxWCharToAcpLengthRatio;
+ full_name = full_namePS.OpenStringBuffer(length);
path_size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, full_name,
- MAX_LONGPATH, NULL, NULL );
+ length, NULL, NULL );
+ full_namePS.CloseBuffer(path_size);
+
if( path_size == 0 )
{
DWORD dwLastError = GetLastError();
if (lpPrefixString != NULL)
{
+ length = (PAL_wcslen(lpPrefixString)+1) * MaxWCharToAcpLengthRatio;
+ prefix_string = prefix_stringPS.OpenStringBuffer(length);
prefix_size = WideCharToMultiByte( CP_ACP, 0, lpPrefixString, -1,
prefix_string,
MAX_LONGPATH - path_size - MAX_SEEDSIZE,
NULL, NULL );
+ prefix_stringPS.CloseBuffer(prefix_size);
+
if( prefix_size == 0 )
{
DWORD dwLastError = GetLastError();
goto done;
}
}
-
+
+ tempfile_name = new char[MAX_LONGPATH+1];
+ if (tempfile_name == NULL)
+ {
+ pThread->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ uRet = 0;
+ goto done;
+ }
+
uRet = GetTempFileNameA(full_name,
(lpPrefixString == NULL) ? NULL : prefix_string,
0, tempfile_name);
-
- if ( uRet && !MultiByteToWideChar( CP_ACP, 0, tempfile_name, -1,
- lpTempFileName, MAX_PATH_FNAME ))
+
+ path_size = MultiByteToWideChar( CP_ACP, 0, tempfile_name, -1,
+ lpTempFileName, MAX_LONGPATH );
+
+ delete [] tempfile_name;
+ tempfile_name = NULL;
+ if ( uRet && !path_size)
{
DWORD dwLastError = GetLastError();
if (dwLastError == ERROR_INSUFFICIENT_BUFFER)
{
- WARN("File names larger than MAX_PATH_FNAME (%d)! \n", MAX_PATH_FNAME);
+ WARN("File names larger than MAX_PATH_FNAME (%d)! \n", MAX_LONGPATH);
dwLastError = ERROR_FILENAME_EXCED_RANGE;
}
else
uRet = 0;
goto done;
}
+
done:
LOGEXIT("GetTempFileNameW returns UINT %u\n", uRet);
BOOL FILEGetFileNameFromSymLink(char *source)
{
int ret;
- char sLinkData[MAX_LONGPATH];
+ char * sLinkData = new char[MAX_LONGPATH+1];
do
{
if (ret>0)
{
sLinkData[ret] = '\0';
- strcpy_s(source, sizeof(sLinkData), sLinkData);
+ strcpy_s(source, sizeof(char)*(MAX_LONGPATH+1), sLinkData);
}
} while (ret > 0);
+ delete [] sLinkData;
return (errno == EINVAL);
}
#include "pal/thread.hpp"
#include "pal/malloc.hpp"
#include "pal/file.hpp"
+#include "pal/stackstring.hpp"
#include "pal/palinternal.h"
#include "pal/dbgmsg.h"
glob_t *pgGlob )
{
int Ret;
- char Pattern[MAX_LONGPATH];
- char EscapedPattern[2*MAX_LONGPATH];
+ PathCharString PatternPS;
+ PathCharString EscapedPatternPS;
+ char * Pattern;
+ int length = 0;
+ char * EscapedPattern;
TRACE("We shall attempt to glob from components [%s][%s][%s]\n",
dir?dir:"NULL", fname?fname:"NULL", ext?ext:"NULL");
- FILEMakePathA( Pattern, MAX_LONGPATH, dir, fname, ext );
+ if (dir) length = strlen(dir);
+ if (fname) length += strlen(fname);
+ if (ext) length += strlen(ext);
+
+ Pattern = PatternPS.OpenStringBuffer(length);
+ FILEMakePathA( Pattern, length+1, dir, fname, ext );
+ PatternPS.CloseBuffer(length);
TRACE("Assembled Pattern = [%s]\n", Pattern);
/* special handling is needed to handle the case where
filename contains '[' and ']' */
+ EscapedPattern = EscapedPatternPS.OpenStringBuffer(length*2);
FILEEscapeSquareBrackets( Pattern, EscapedPattern);
+ EscapedPatternPS.CloseBuffer(strlen(EscapedPattern));
#ifdef GLOB_QUOTE
flags |= GLOB_QUOTE;
#endif // GLOB_QUOTE
#include "pal/dbgmsg.h"
#include "pal/file.h"
#include "pal/malloc.hpp"
+#include "pal/stackstring.hpp"
#include <errno.h>
LPSTR fileNameA;
/* bufferA needs to be able to hold a path that's potentially as
large as MAX_LONGPATH WCHARs. */
- CHAR bufferA[MAX_LONGPATH * sizeof(WCHAR)];
+ CHAR * bufferA;
+ size_t bufferASize = 0;
+ PathCharString bufferAPS;
LPSTR lpFilePartA;
int fileNameLength;
int srcSize;
to ANSI. This may be more than MAX_LONGPATH. We try to
handle that case, since it may be less than MAX_LONGPATH
WCHARs. */
+
fileNameLength = WideCharToMultiByte(CP_ACP, 0, lpFileName,
-1, NULL, 0, NULL, NULL);
if (fileNameLength == 0)
goto done;
}
- length = GetFullPathNameA(fileNameA, sizeof(bufferA), bufferA, &lpFilePartA);
+ bufferASize = MAX_LONGPATH * sizeof(WCHAR);
+ bufferA = bufferAPS.OpenStringBuffer(bufferASize);
+
+ length = GetFullPathNameA(fileNameA, bufferASize, bufferA, &lpFilePartA);
+ bufferAPS.CloseBuffer(length);
- if (length == 0 || length > sizeof(bufferA))
+ if (length == 0 || length > bufferASize)
{
/* Last error is set by GetFullPathNameA */
nRet = length;
)
{
DWORD nRet = 0;
- CHAR FullPath[MAX_LONGPATH];
- CHAR CanonicalFullPath[MAX_LONGPATH];
+ CHAR * FullPath;
+ size_t FullPathLength = 0;
+ PathCharString FullPathPS;
+ PathCharString CanonicalFullPathPS;
+ CHAR * CanonicalFullPath;
LPCSTR pPathStart;
LPCSTR pPathEnd;
size_t PathLength;
goto done;
}
/* Canonicalize the path to deal with back-to-back '/', etc. */
+ CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(MAX_LONGPATH);
dw = GetFullPathNameA(lpFileName, MAX_LONGPATH, CanonicalFullPath, NULL);
- if (dw == 0 || dw >= MAX_LONGPATH)
+ CanonicalFullPathPS.CloseBuffer(dw);
+
+ if (dw > MAX_LONGPATH+1)
+ {
+ CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1);
+ dw = GetFullPathNameA(lpFileName, dw,
+ CanonicalFullPath, NULL);
+ CanonicalFullPathPS.CloseBuffer(dw);
+ }
+
+ if (dw == 0)
{
WARN("couldn't canonicalize path <%s>, error is %#x. failing.\n",
- FullPath, GetLastError());
+ lpFileName, GetLastError());
SetLastError(ERROR_INVALID_PARAMETER);
goto done;
}
/* Construct a pathname by concatenating one path from lpPath, '/'
and lpFileName */
+ FullPathLength = PathLength + FileNameLength;
+ FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1);
memcpy(FullPath, pPathStart, PathLength);
FullPath[PathLength] = '/';
if (strcpy_s(&FullPath[PathLength+1], MAX_LONGPATH-PathLength, lpFileName) != SAFECRT_SUCCESS)
{
+ FullPathPS.CloseBuffer(0);
ERROR("strcpy_s failed!\n");
SetLastError( ERROR_FILENAME_EXCED_RANGE );
nRet = 0;
goto done;
}
+ FullPathPS.CloseBuffer(FullPathLength+1);
/* Canonicalize the path to deal with back-to-back '/', etc. */
+ CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(MAX_LONGPATH);
dw = GetFullPathNameA(FullPath, MAX_LONGPATH,
CanonicalFullPath, NULL);
- if (dw == 0 || dw >= MAX_LONGPATH)
+ CanonicalFullPathPS.CloseBuffer(dw);
+
+ if (dw > MAX_LONGPATH+1)
+ {
+ CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1);
+ dw = GetFullPathNameA(FullPath, dw,
+ CanonicalFullPath, NULL);
+ CanonicalFullPathPS.CloseBuffer(dw);
+ }
+
+ if (dw == 0)
{
/* Call failed - possibly low memory. Skip the path */
WARN("couldn't canonicalize path <%s>, error is %#x. "
)
{
DWORD nRet = 0;
- WCHAR FullPath[MAX_LONGPATH];
+ WCHAR * FullPath;
+ size_t FullPathLength = 0;
+ PathWCharString FullPathPS;
LPCWSTR pPathStart;
LPCWSTR pPathEnd;
size_t PathLength;
size_t FileNameLength;
DWORD dw;
- char AnsiPath[MAX_LONGPATH];
- WCHAR CanonicalPath[MAX_LONGPATH];
+ char * AnsiPath;
+ PathCharString AnsiPathPS;
+ size_t CanonicalPathLength;
+ int canonical_size;
+ WCHAR * CanonicalPath;
+ PathWCharString CanonicalPathPS;
PERF_ENTRY(SearchPathW);
ENTRY("SearchPathW(lpPath=%p (%S), lpFileName=%p (%S), lpExtension=%p, "
if('\\' == lpFileName[0] || '/' == lpFileName[0])
{
/* Canonicalize the path to deal with back-to-back '/', etc. */
+ CanonicalPath = CanonicalPathPS.OpenStringBuffer(MAX_LONGPATH);
dw = GetFullPathNameW(lpFileName, MAX_LONGPATH, CanonicalPath, NULL);
- if (dw == 0 || dw >= MAX_LONGPATH)
+ CanonicalPathPS.CloseBuffer(dw);
+ if (dw > MAX_LONGPATH+1)
+ {
+ CanonicalPath = CanonicalPathPS.OpenStringBuffer(dw-1);
+ dw = GetFullPathNameW(lpFileName, dw, CanonicalPath, NULL);
+ CanonicalPathPS.CloseBuffer(dw);
+ }
+
+ if (dw == 0)
{
WARN("couldn't canonicalize path <%S>, error is %#x. failing.\n",
lpPath, GetLastError());
}
/* see if the file exists */
- WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1,
- AnsiPath, MAX_LONGPATH, NULL, NULL);
+ CanonicalPathLength = (PAL_wcslen(CanonicalPath)+1)*3;
+ AnsiPath = AnsiPathPS.OpenStringBuffer(CanonicalPathLength);
+ canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1,
+ AnsiPath, CanonicalPathLength, NULL, NULL);
+ AnsiPathPS.CloseBuffer(canonical_size);
+
if(0 == access(AnsiPath, F_OK))
{
/* found it */
/* Construct a pathname by concatenating one path from lpPath, '/'
and lpFileName */
+ FullPathLength = PathLength + FileNameLength;
+ FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1);
memcpy(FullPath, pPathStart, PathLength*sizeof(WCHAR));
FullPath[PathLength] = '/';
PAL_wcscpy(&FullPath[PathLength+1], lpFileName);
+
+ FullPathPS.CloseBuffer(FullPathLength+1);
/* Canonicalize the path to deal with back-to-back '/', etc. */
+ CanonicalPath = CanonicalPathPS.OpenStringBuffer(MAX_LONGPATH);
dw = GetFullPathNameW(FullPath, MAX_LONGPATH,
CanonicalPath, NULL);
- if (dw == 0 || dw >= MAX_LONGPATH)
+ CanonicalPathPS.CloseBuffer(dw);
+
+ if (dw > MAX_LONGPATH+1)
+ {
+ CanonicalPath = CanonicalPathPS.OpenStringBuffer(dw-1);
+ dw = GetFullPathNameW(FullPath, dw, CanonicalPath, NULL);
+ CanonicalPathPS.CloseBuffer(dw);
+ }
+
+ if (dw == 0)
{
/* Call failed - possibly low memory. Skip the path */
WARN("couldn't canonicalize path <%S>, error is %#x. "
}
/* see if the file exists */
- WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1,
- AnsiPath, MAX_LONGPATH, NULL, NULL);
+ CanonicalPathLength = (PAL_wcslen(CanonicalPath)+1) * 3;
+ AnsiPath = AnsiPathPS.OpenStringBuffer(CanonicalPathLength);
+ canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1,
+ AnsiPath, CanonicalPathLength, NULL, NULL);
+ AnsiPathPS.CloseBuffer(canonical_size);
+
if(0 == access(AnsiPath, F_OK))
{
/* found it */
#define _PAL_MAP_H_
#include "corunix.hpp"
+#include <sys/param.h>
extern "C"
{
class CFileMappingImmutableData
{
public:
- CHAR szFileName[MAX_LONGPATH + 1];
+ CHAR szFileName[MAXPATHLEN];
UINT MaxSize; // The max size of the file mapping object
DWORD flProtect; // Protection desired for the file view
BOOL bPALCreatedTempFile; // TRUE if it's a PAL created file
private:
T m_innerBuffer[STACKCOUNT + 1];
T * m_buffer;
- SIZE_T m_count; // actual allocated count
+ SIZE_T m_size; // actual allocated size
+ SIZE_T m_count; // actual length of string
void NullTerminate()
{
DeleteBuffer();
m_buffer = newBuffer;
m_count = count;
+ m_size = count+1;
return;
}
}
else
{
+ m_size = STACKCOUNT+1;
m_buffer = m_innerBuffer;
m_count = count;
}
else if (m_innerBuffer == m_buffer)
{
if (count > STACKCOUNT)
+ {
ReallocateBuffer(count);
+ }
else
+ {
m_count = count;
+ m_size = STACKCOUNT+1;
+ }
}
else
{
SIZE_T GetSizeOf() const
{
- return (m_count+1) * sizeof(T);
+ return m_size * sizeof(T);
}
CONST T * GetString() const
#include "pal/misc.h"
#include "pal/virtual.h"
#include "pal/map.hpp"
+#include "pal/stackstring.hpp"
#include <sys/param.h>
#include <errno.h>
MODSTRUCT exe_module;
MODSTRUCT *pal_module = NULL;
-char g_szCoreCLRPath[MAX_LONGPATH] = { 0 };
+char * g_szCoreCLRPath = NULL;
+size_t g_cbszCoreCLRPath = (MAX_LONGPATH+1) * sizeof(char);
+int MaxWCharToAcpLength = 3;
/* static function declarations ***********************************************/
template<class TChar> bool LOADVerifyLibraryPath(const TChar *libraryPath);
bool LOADConvertLibraryPathWideStringToMultibyteString(
LPCWSTR wideLibraryPath,
- CHAR (&multibyteLibraryPath)[MAX_LONGPATH],
+ LPSTR multibyteLibraryPath,
INT *multibyteLibraryPathLengthRef);
static BOOL LOADValidateModule(MODSTRUCT *module);
return NULL;
}
- CHAR lpstr[MAX_LONGPATH];
+ CHAR * lpstr;
INT name_length;
+ PathCharString pathstr;
HMODULE hModule = NULL;
PERF_ENTRY(LoadLibraryExW);
goto done;
}
+ lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength);
if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length))
{
goto done;
/* do the Dos/Unix conversion on our own copy of the name */
FILEDosToUnixPathA(lpstr);
+ pathstr.CloseBuffer(name_length);
/* let LOADLoadLibrary call SetLastError in case of failure */
hModule = LOADLoadLibrary(lpstr, TRUE);
PAL_LoadLibraryDirect(
IN LPCWSTR lpLibFileName)
{
- CHAR lpstr[MAX_LONGPATH];
+ PathCharString pathstr;
+ CHAR * lpstr = NULL;
INT name_length;
HMODULE hModule = NULL;
{
goto done;
}
+
+ lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength);
if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length))
{
/* do the Dos/Unix conversion on our own copy of the name */
FILEDosToUnixPathA(lpstr);
+ pathstr.CloseBuffer(name_length);
/* let LOADLoadLibraryDirect call SetLastError in case of failure */
hModule = LOADLoadLibraryDirect(lpstr, true /* setLastError */);
IN HMODULE dl_handle,
IN LPCWSTR lpLibFileName)
{
- CHAR lpstr[MAX_LONGPATH];
+ PathCharString pathstr;
+ CHAR * lpstr = NULL;
INT name_length;
HMODULE hModule = NULL;
goto done;
}
+ lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength);
if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length))
{
goto done;
/* do the Dos/Unix conversion on our own copy of the name */
FILEDosToUnixPathA(lpstr);
+ pathstr.CloseBuffer(name_length);
/* let LOADRegisterLibraryDirect call SetLastError in case of failure */
LockModuleList();
// Converts the wide char library path string into a multibyte-char string. On error, calls SetLastError() and returns false.
bool LOADConvertLibraryPathWideStringToMultibyteString(
LPCWSTR wideLibraryPath,
- CHAR(&multibyteLibraryPath)[MAX_LONGPATH],
+ LPSTR multibyteLibraryPath,
INT *multibyteLibraryPathLengthRef)
{
- _ASSERTE(wideLibraryPath != nullptr);
_ASSERTE(multibyteLibraryPathLengthRef != nullptr);
+ _ASSERTE(wideLibraryPath != nullptr);
+ size_t length = (PAL_wcslen(wideLibraryPath)+1) * MaxWCharToAcpLength;
*multibyteLibraryPathLengthRef = WideCharToMultiByte(CP_ACP, 0, wideLibraryPath, -1, multibyteLibraryPath,
- MAX_LONGPATH, nullptr, nullptr);
+ length, nullptr, nullptr);
+
if (*multibyteLibraryPathLengthRef == 0)
{
DWORD dwLastError = GetLastError();
--*/
static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic)
{
- CHAR fullLibraryName[MAX_LONGPATH];
+ CHAR * fullLibraryName;
+ PathCharString fullLibraryNamePS;
HMODULE module = NULL;
HMODULE dl_handle = NULL;
continue;
_ASSERTE(dl_handle == nullptr);
- if (snprintf(fullLibraryName, MAX_LONGPATH, formatStrings[i], PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX) < MAX_LONGPATH)
+ fullLibraryName = fullLibraryNamePS.OpenStringBuffer(strlen(PAL_SHLIB_PREFIX)+strlen(shortAsciiName)+strlen(PAL_SHLIB_SUFFIX));
+ int size = snprintf(fullLibraryName, fullLibraryNamePS.GetSizeOf(), formatStrings[i], PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX);
+ if (size < fullLibraryNamePS.GetSizeOf())
{
+ fullLibraryNamePS.CloseBuffer(size);
dl_handle = LOADLoadLibraryDirect(fullLibraryName, false /* setLastError */);
if (dl_handle != nullptr)
{
}
// Stash a copy of the CoreCLR installation path in a global variable.
// Make sure it's terminated with a slash.
- if (strcpy_s(g_szCoreCLRPath, sizeof(g_szCoreCLRPath), info.dli_fname) != SAFECRT_SUCCESS)
+ if (g_szCoreCLRPath == NULL)
+ {
+ g_szCoreCLRPath = new char[g_cbszCoreCLRPath/sizeof(char)];
+ }
+
+ if (strcpy_s(g_szCoreCLRPath, g_cbszCoreCLRPath, info.dli_fname) != SAFECRT_SUCCESS)
{
ERROR("LOADGetPalLibrary: strcpy_s failed!");
goto exit;
#include "pal/utf8.h"
#include "pal/locale.h"
#include "pal/cruntime.h"
+#include "pal/stackstring.hpp"
#if !(HAVE_PTHREAD_RWLOCK_T || HAVE_COREFOUNDATION)
#error Either pthread rwlocks or Core Foundation are required for Unicode support
return retval;
}
-extern char g_szCoreCLRPath[MAX_LONGPATH];
+extern char * g_szCoreCLRPath;
/*++
Function :
PAL_BindResources(IN LPCSTR lpDomain)
{
#ifndef __APPLE__
- char coreCLRDirectoryPath[MAX_LONGPATH];
-
- INDEBUG(DWORD size = )
- FILEGetDirectoryFromFullPathA(g_szCoreCLRPath, MAX_LONGPATH, coreCLRDirectoryPath);
+ _ASSERTE(g_szCoreCLRPath != NULL);
+ char * coreCLRDirectoryPath;
+ PathCharString coreCLRDirectoryPathPS;
+ int len = strlen(g_szCoreCLRPath);
+ coreCLRDirectoryPath = coreCLRDirectoryPathPS.OpenStringBuffer(len);
+ DWORD size = FILEGetDirectoryFromFullPathA(g_szCoreCLRPath, len, coreCLRDirectoryPath);
+ coreCLRDirectoryPathPS.CloseBuffer(size);
_ASSERTE(size <= MAX_LONGPATH);
LPCSTR boundPath = bindtextdomain(lpDomain, coreCLRDirectoryPath);
static void PERFPrintProgramHeaderInfo(PERF_FILE * hFile, BOOL completedExecution);
static BOOL PERFInitProgramInfo(LPWSTR command_line, LPWSTR exe_path);
static BOOL PERFReadSetting( );
-static void PERFLogFileName(char *destFileName, const char *fileName, const char *suffix, int max_length);
+static void PERFLogFileName(PathCharString destFileString, const char *fileName, const char *suffix, int max_length);
static void PERFlushAllLogs();
static int PERFWriteCounters(pal_perf_api_info * table);
static BOOL PERFFlushLog(pal_perf_thread_info * local_buffer, BOOL output_header);
static
void
-PERFLogFileName(char *destFileName, const char *fileName, const char *suffix, int max_length)
+PERFLogFileName(PathCharString * destFileString, const char *fileName, const char *suffix, int max_length)
{
const char *dir_path;
+ char * destFileName = new char[max_length];
dir_path = (profile_log_path == NULL) ? "." : profile_log_path;
if (fileName != NULL)
snprintf(destFileName, max_length, "%s%s%d_%d%s", dir_path, PATH_SEPARATOR,
program_info.process_id, THREADSilentGetCurrentThreadId(), suffix);
}
-
+
+ destFileString.Set(destFileName);
+ delete [] destFileName;
+ destFileName = NULL;
}
static
int
PERFWriteCounters( pal_perf_api_info * table )
{
- char fileName[MAX_LONGPATH];
+ PathCharString fileName;
pal_perf_api_info * off;
PERF_FILE * hFile;
int i;
off = table;
- PERFLogFileName(fileName, profile_summary_log_name, "_perf_summary.log", MAX_LONGPATH);
+
+ PERFLogFileName(&fileName, profile_summary_log_name, "_perf_summary.log", MAX_LONGPATH);
hFile = PERF_FILEFN(fopen)(fileName, "a+");
if(hFile != NULL)
{
if (pal_perf_histogram_size > 0)
{
off = table;
- PERFLogFileName(fileName, profile_summary_log_name, "_perf_summary.hist", MAX_LONGPATH);
+ PERFLogFileName(&fileName, profile_summary_log_name, "_perf_summary.hist", MAX_LONGPATH);
hFile = PERF_FILEFN(fopen)(fileName, "a+");
if (hFile != NULL)
char * ptr;
char function_name[PAL_PERF_MAX_FUNCTION_NAME]; //no function can be longer than 127 bytes.
- char file_name_buf[MAX_LONGPATH];
+ char * file_name_buf;
+ PathCharString file_name_bufPS;
char * input_file_name;
char * summary_flag_env;
char * nested_tracing_env;
{
if( PERFIsValidFile(perf_default_path,traced_apis_filename))
{
- if ((strcpy_s(file_name_buf, sizeof(file_name_buf), perf_default_path) != SAFECRT_SUCCESS) ||
- (strcat_s(file_name_buf, sizeof(file_name_buf), PATH_SEPARATOR) != SAFECRT_SUCCESS) ||
- (strcat_s(file_name_buf, sizeof(file_name_buf), traced_apis_filename) != SAFECRT_SUCCESS))
+ int length = strlen(perf_default_path) + strlen(PATH_SEPARATOR) + strlen(traced_apis_filename);
+ file_name_buf = file_name_bufPS.OpenStringBuffer(length);
+ if ((strcpy_s(file_name_buf, file_name_bufPS.GetSizeOf(), perf_default_path) != SAFECRT_SUCCESS) ||
+ (strcat_s(file_name_buf, file_name_bufPS.GetSizeOf(), PATH_SEPARATOR) != SAFECRT_SUCCESS) ||
+ (strcat_s(file_name_buf, file_name_bufPS.GetSizeOf(), traced_apis_filename) != SAFECRT_SUCCESS))
{
+ file_name_bufPS.CloseBuffer(0);
ret = FALSE;
input_file_name = NULL;
}
else
{
+ file_name_bufPS.CloseBuffer(length);
input_file_name = file_name_buf;
}
}
PERFFlushLog(pal_perf_thread_info * local_info, BOOL output_header)
{
BOOL ret = FALSE;
- char fileName[MAX_LONGPATH];
+ PathCharString fileName;
int nWrittenBytes = 0;
PERF_FILE * hFile;
if (summary_only)
return TRUE;
- PERFLogFileName(fileName, profile_time_log_name, "_perf_time.log", MAX_LONGPATH);
+ PERFLogFileName(&fileName, profile_time_log_name, "_perf_time.log", MAX_LONGPATH);
hFile = PERF_FILEFN(fopen)(fileName, "a+");
PERF_FILEFN(fclose)(hFile);
ret = TRUE;
}
+
+ delete [] fileName;
+ fileName = NULL;
+
return ret;
}
PERFIsValidFile( const char * path, const char * file)
{
FILE * hFile;
- char temp[MAX_LONGPATH];
+ char * temp;
+ PathCharString tempPS;
if(file==NULL || strlen(file)==0)
return NULL;
if ( strcmp(path, "") )
- {
+ {
+ int length = strlen(path) + strlen(PATH_SEPARATOR) + strlen(file);
+ temp = tempPS.OpenStringBuffer(length);
if ((strcpy_s(temp, sizeof(temp), path) != SAFECRT_SUCCESS) ||
(strcat_s(temp, sizeof(temp), PATH_SEPARATOR) != SAFECRT_SUCCESS) ||
(strcat_s(temp, sizeof(temp), file) != SAFECRT_SUCCESS))
{
+ tempPS.CloseBuffer(0);
return NULL;
}
+ tempPS.CloseBuffer(length);
hFile = fopen(temp, "r");
}
else
#ifndef CORECLR
/* suffix template for mkstemp */
-static char segment_name_template[MAX_LONGPATH];
-static char lockfile_name[MAX_LONGPATH];
+static char segment_name_template[MAX_PATH];
+static char lockfile_name[MAX_PATH];
#endif // !defined(CORECLR)
/* Constants ******************************************************************/
int fd_map;
int i;
int j;
- CHAR config_dir[MAX_LONGPATH];
- CHAR first_segment_name[MAX_LONGPATH];
+ CHAR config_dir[MAX_PATH];
+ CHAR first_segment_name[MAX_PATH];
ssize_t sBytes;
#endif // !CORECLR
init_waste();
#ifndef CORECLR
- if ( PALGetPalConfigDir( config_dir, MAX_LONGPATH ) )
+ if ( PALGetPalConfigDir( config_dir, MAX_PATH ) )
{
if ( ( strlen( config_dir ) + strlen( segment_name_prefix ) +
/* + 3 for the / _ and \0 */
- strlen( first_segment_suffix ) + 3 ) < MAX_LONGPATH &&
+ strlen( first_segment_suffix ) + 3 ) < MAX_PATH &&
( strlen( config_dir ) + strlen( segment_name_prefix ) +
- SEGMENT_NAME_SUFFIX_LENGTH + 3 ) < MAX_LONGPATH )
+ SEGMENT_NAME_SUFFIX_LENGTH + 3 ) < MAX_PATH )
{
/* build first segment's file name */
sprintf( first_segment_name,"%s/%s_%s", config_dir,
else
{
ASSERT( "Configuration directory length + segment name length "
- "is greater then MAX_LONGPATH.\n" );
+ "is greater then MAX_PATH.\n" );
return FALSE;
}
}
}
else /* Clean up everything. */
{
- CHAR PalDir[ MAX_LONGPATH + 1 ];
- CHAR FileName[ MAX_LONGPATH + 1 ];
+ CHAR PalDir[ MAX_PATH + 1 ];
+ CHAR FileName[ MAX_PATH + 1 ];
UINT nEndOfPathAndPrefix = 0;
SHM_SEGMENT_HEADER segment_header;
LPCSTR suffix;
int fd_segment;
/* Build start of filename. */
- if ( !PALGetPalConfigDir( PalDir, MAX_LONGPATH ) )
+ if ( !PALGetPalConfigDir( PalDir, MAX_PATH ) )
{
ASSERT( "Unable to determine the PAL config directory.\n" );
#ifdef O_EXLOCK
--*/
static LPVOID SHMMapSegment(char *segment_name)
{
- char segment_path[MAX_LONGPATH];
+ char segment_path[MAX_PATH];
int segment_fd;
LPVOID *segment;
struct stat sb;
/* Construct the file's full path */
- if ( !PALGetPalConfigDir( segment_path, MAX_LONGPATH ) )
+ if ( !PALGetPalConfigDir( segment_path, MAX_PATH ) )
{
ASSERT( "Unable to determine the PAL config directory.\n" );
return NULL;
static BOOL SHMAddSegment(void)
{
#ifndef CORECLR
- char segment_name[MAX_LONGPATH];
+ char segment_name[MAX_PATH];
char *suffix_start;
int fd_map;
#endif // !CORECLR
{
int fd;
FILE *log_file;
- char file_name[MAX_LONGPATH];
+ char file_name[MAX_PATH];
enum SHM_POOL_SIZES sps;
int avg;
LPSTR env_string;
return;
}
- if ( !PALGetPalConfigDir( file_name, MAX_LONGPATH ) )
+ if ( !PALGetPalConfigDir( file_name, MAX_PATH ) )
{
ERROR( "Unable to determine the PAL config directory.\n" );
return;
PAL_ERROR palErr = NO_ERROR;
int iProcessPipe, iBytesToWrite, iRetryCount;
ssize_t sszRet;
- char strPipeFilename[MAX_LONGPATH];
+ char strPipeFilename[MAX_PATH];
BYTE * pPos = pMsg;
bool fRet;
CPalThread *pthrCurrent = InternalGetCurrentThread();
"SendMsgToRemoteWorker called with local process as "
"target process\n");
- fRet = GetProcessPipeName(strPipeFilename, MAX_LONGPATH, dwProcessId);
+ fRet = GetProcessPipeName(strPipeFilename, MAX_PATH, dwProcessId);
_ASSERT_MSG(fRet, "Failed to retrieve process pipe's name!\n");
#ifndef CORECLR
int iPipeRd = -1, iPipeWr = -1;
- char szPipeFilename[MAX_LONGPATH];
+ char szPipeFilename[MAX_PATH];
/* Create the blocking pipe */
- if(!GetProcessPipeName(szPipeFilename, MAX_LONGPATH, gPID))
+ if(!GetProcessPipeName(szPipeFilename, MAX_PATH, gPID))
{
ERROR("couldn't get process pipe's name\n");
szPipeFilename[0] = 0;
{
PAL_ERROR palErr = NO_ERROR;
#ifndef CORECLR
- char szPipeFilename[MAX_LONGPATH];
+ char szPipeFilename[MAX_PATH];
- if(GetProcessPipeName(szPipeFilename, MAX_LONGPATH, gPID))
+ if(GetProcessPipeName(szPipeFilename, MAX_PATH, gPID))
{
if (InternalUnlink(pthrCurrent, szPipeFilename) == -1)
{
int iDestSize,
DWORD dwPid)
{
- CHAR config_dir[MAX_LONGPATH];
+ CHAR config_dir[MAX_PATH];
int needed_size;
_ASSERT_MSG(NULL != pDest, "Destination pointer is NULL!\n");
_ASSERT_MSG(0 < iDestSize,"Invalid buffer size %d\n", iDestSize);
- if (!PALGetPalConfigDir(config_dir, MAX_LONGPATH))
+ if (!PALGetPalConfigDir(config_dir, MAX_PATH))
{
ASSERT("Unable to determine the PAL config directory.\n");
pDest[0] = '\0';
#include "pal/utils.h"
#include "pal/misc.h"
#include "pal/virtual.h"
+#include "pal/stackstring.hpp"
#include <errno.h>
#if HAVE_POLL
int iFdErr = -1;
pid_t processId;
- char lpFileName[MAX_LONGPATH] ;
+ char * lpFileName = new char[MAX_LONGPATH];
char **lppArgv = NULL;
UINT nArg;
int iRet;
palError = ERROR_INVALID_PARAMETER;
goto InternalCreateProcessExit;
}
+
+ if (NULL == lpFileName)
+ {
+ palError = ERROR_NOT_ENOUGH_MEMORY;
+ goto InternalCreateProcessExit;
+ }
if (0 != (dwCreationFlags & ~(CREATE_SUSPENDED|CREATE_NEW_CONSOLE)))
{
if ( PAL_GetPALDirectoryA( lpFileName,
(MAX_LONGPATH - (strlen(PROCESS_PELOADER_FILENAME)+1))))
{
- if ((strcat_s(lpFileName, sizeof(lpFileName), "/") != SAFECRT_SUCCESS) ||
- (strcat_s(lpFileName, sizeof(lpFileName), PROCESS_PELOADER_FILENAME) != SAFECRT_SUCCESS))
+ if ((strcat_s(lpFileName, sizeof(char) * MAX_LONGPATH, "/") != SAFECRT_SUCCESS) ||
+ (strcat_s(lpFileName, sizeof(char) * MAX_LONGPATH, PROCESS_PELOADER_FILENAME) != SAFECRT_SUCCESS))
{
ERROR("strcpy_s/strcat_s failed!\n");
palError = ERROR_INTERNAL_ERROR;
{
LPWSTR lpEnd;
WCHAR wcEnd;
- char lpFileName[MAX_LONGPATH];
+ char * lpFileName;
+ PathCharString lpFileNamePS;
char *lpTemp;
if (lpApplicationName)
*lpEnd = 0x0000;
/* Convert to ASCII */
- if (!WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1,
- lpFileName, MAX_LONGPATH, NULL, NULL))
+ int size = 0;
+ int length = (PAL_wcslen(lpCommandLine)+1) * sizeof(WCHAR);
+ lpFileName = lpFileNamePS.OpenStringBuffer(length);
+ if (!(size = WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1,
+ lpFileName, length, NULL, NULL)))
{
ASSERT("WideCharToMultiByte failure\n");
return FALSE;
}
+ lpFileNamePS.CloseBuffer(size);
/* restore last character */
*lpEnd = wcEnd;
DestroyProcessModules(pProcessModules);
}
}
-
\ No newline at end of file
+
Fail ("SearchPathA: ERROR2 -> Did not Find valid file[%s][%s][%d]\n", lpPath, szFileNameExistsWithExt, error);
}
- RemoveAll();
+ /*RemoveAll();*/
PAL_Terminate();
return PASS;
}