Exemplo n.º 1
0
int
TclpRenameFile(
    CONST char *src,		/* Pathname of file or dir to be renamed
				 * (UTF-8). */
    CONST char *dst)		/* New pathname of file or directory
				 * (UTF-8). */
{
    int result;
    TCHAR *nativeSrc;
    Tcl_DString srcString, dstString;

    nativeSrc = Tcl_WinUtfToTChar(src, -1, &srcString);
    Tcl_WinUtfToTChar(dst, -1, &dstString);

    if ((TclWinGetPlatformId() == VER_PLATFORM_WIN32s) 
	    && ((Tcl_DStringLength(&srcString) >= MAX_PATH - 1) ||
		    (Tcl_DStringLength(&dstString) >= MAX_PATH - 1))) {
	/*
	 * On Win32s, really long file names cause the MoveFile() call
	 * to lock up, endlessly throwing an access violation and 
	 * retrying the operation.
	 */

	errno = ENAMETOOLONG;
	result = TCL_ERROR;
    } else {
	result = DoRenameFile(nativeSrc, &dstString);
    }
    Tcl_DStringFree(&srcString);
    Tcl_DStringFree(&dstString);
    return result;
}
Exemplo n.º 2
0
void FileFunctionsTestCase::RenameFile()
{
    // Verify renaming file with/without overwriting
    // when new file already exist/don't exist.
    DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, false);
    DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, true);
    DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, true, false);
    DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, true, true);
    DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, false, false);
    DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, false, true);
    DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, false);
    DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, true);
}