Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/fileswn4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ void CFilesWindow::DrawBriefDetailedItem(HDC hTgtDC, int itemIndex, RECT* itemRe
nameLenW = (int)f->NameW.length();
// For Unicode names, we don't apply AlterFileName transformation yet
// (TODO: add AlterFileNameW for proper uppercase/lowercase handling)

}

CColumn* column = &Columns[0];
Expand All @@ -704,8 +705,10 @@ void CFilesWindow::DrawBriefDetailedItem(HDC hTgtDC, int itemIndex, RECT* itemRe
{
textWidth = nameWidth - 1 - IconSizes[ICONSIZE_16] - 1 - 2 - SPACE_WIDTH;
if (useWideDisplay)
{
GetTextExtentExPointW(hDC, f->NameW.c_str(), nameLenW, textWidth,
&fitChars, DrawItemAlpDx, &fnSZ);
}
else
GetTextExtentExPoint(hDC, TransferBuffer, nameLen, textWidth,
&fitChars, DrawItemAlpDx, &fnSZ);
Expand Down Expand Up @@ -736,8 +739,10 @@ void CFilesWindow::DrawBriefDetailedItem(HDC hTgtDC, int itemIndex, RECT* itemRe
// the string may be longer than the available space and must end with "..."
textWidth = nameWidth - 1 - IconSizes[ICONSIZE_16] - 1 - 2 - SPACE_WIDTH;
if (useWideDisplay)
{
GetTextExtentExPointW(hDC, f->NameW.c_str(), nameLenW, textWidth,
&fitChars, DrawItemAlpDx, &fnSZ);
}
else
GetTextExtentExPoint(hDC, TransferBuffer, nameLen, textWidth,
&fitChars, DrawItemAlpDx, &fnSZ);
Expand Down Expand Up @@ -881,7 +886,9 @@ void CFilesWindow::DrawBriefDetailedItem(HDC hTgtDC, int itemIndex, RECT* itemRe
{
// extension is an exception - it always follows Name and we handle it explicitly
if (isDir && !Configuration.SortDirsByExt || f->Ext[0] == 0 || f->Ext <= f->Name + 1) // empty value in the Ext column (exception for names like ".htaccess", they appear in the Name column even though they are extensions)
{
TransferLen = 0;
}
else if (f->UseWideName())
{
// For Unicode filenames, find extension in NameW instead of using ANSI offset
Expand All @@ -902,7 +909,10 @@ void CFilesWindow::DrawBriefDetailedItem(HDC hTgtDC, int itemIndex, RECT* itemRe
AlterFileName(TransferBuffer, f->Name, -1, Configuration.FileNameFormat, 0, isDir);
TransferLen = (int)(f->NameLen - (f->Ext - f->Name));
if (TransferLen > 0)
{
MoveMemory(TransferBuffer, TransferBuffer + (f->Ext - f->Name), TransferLen); // buffer overlap may occur
TransferBuffer[TransferLen] = 0;
}
}
}

Expand Down
20 changes: 16 additions & 4 deletions src/fileswn6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ BOOL CFilesWindow::BuildScriptMain2(COperations* script, BOOL copy, char* target
wideNameOnly = sw + 1; // Points to just the filename
}

DWORD attrs = SalGetFileAttributes(fileName);
// For Unicode files, use wide path to get attributes (ANSI path has ?? for non-convertible chars)
DWORD attrs = (fileNameW != NULL) ? GetFileAttributesW(fileNameW) : SalGetFileAttributes(fileName);
if (attrs != 0xFFFFFFFF)
{
char* s = fileName + strlen(fileName);
Expand Down Expand Up @@ -935,9 +936,20 @@ BOOL CFilesWindow::BuildScriptMain2(COperations* script, BOOL copy, char* target
}
else
{
HANDLE h = HANDLES_Q(CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL));
HANDLE h;
if (fileNameW != NULL)
{
// Use wide path for Unicode filenames (ANSI path has ?? for non-convertible chars)
h = CreateFileW(fileNameW, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD err2 = GetLastError();
HANDLES_ADD_EX(__otQuiet, h != INVALID_HANDLE_VALUE, __htFile, __hoCreateFile, h, err2, TRUE);
}
else
{
h = HANDLES_Q(CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL));
}
DWORD err = NO_ERROR;
if (h != INVALID_HANDLE_VALUE)
{
Expand Down
19 changes: 12 additions & 7 deletions src/fileswn7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void CFilesWindow::UnpackZIPArchive(CFilesWindow* target, BOOL deleteOp, const c
// instead of a 'switch', use 'if' so that 'break' and 'continue' work correctly
if (pathType == PATH_TYPE_WINDOWS) // Windows path (disk + UNC)
{
char newDirs[MAX_PATH]; // if a directory is being created for the operation, remember its name (so we can delete it in case of an error)
CPathBuffer newDirs; // if a directory is being created for the operation, remember its name (so we can delete it in case of an error)
newDirs[0] = 0;

if (pathIsDir) // the existing part of the path is a directory
Expand All @@ -554,7 +554,7 @@ void CFilesWindow::UnpackZIPArchive(CFilesWindow* target, BOOL deleteOp, const c
if (Configuration.CnfrmCreatePath) // ask whether the path should be created
{
BOOL dontShow = FALSE;
sprintf(textBuf, LoadStr(IDS_MOVECOPY_CREATEPATH), newDirs);
sprintf(textBuf, LoadStr(IDS_MOVECOPY_CREATEPATH), newDirs.Get());

MSGBOXEX_PARAMS params;
memset(&params, 0, sizeof(params));
Expand Down Expand Up @@ -604,12 +604,17 @@ void CFilesWindow::UnpackZIPArchive(CFilesWindow* target, BOOL deleteOp, const c
invalidPath = TRUE;
}
}
if (invalidPath || !CreateDirectory(newDirs, NULL))
if (invalidPath || !SalLPCreateDirectory(newDirs, NULL))
{
sprintf(textBuf, LoadStr(IDS_CREATEDIRFAILED), newDirs);
SalMessageBox(HWindow, textBuf, LoadStr(IDS_ERRORCOPY), MB_OK | MB_ICONEXCLAMATION);
ok = FALSE;
break;
DWORD lastErr = invalidPath ? ERROR_INVALID_NAME : GetLastError();
// ERROR_ALREADY_EXISTS is not a failure - the directory is there, which is what we want
if (lastErr != ERROR_ALREADY_EXISTS)
{
sprintf(textBuf, LoadStr(IDS_CREATEDIRFAILED), newDirs.Get());
SalMessageBox(HWindow, textBuf, LoadStr(IDS_ERRORCOPY), MB_OK | MB_ICONEXCLAMATION);
ok = FALSE;
break;
}
}
if (slash != NULL)
*slash = '\\';
Expand Down
12 changes: 12 additions & 0 deletions src/fileswn9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,18 @@ BOOL CFilesWindow::CopyFocusedNameToClipboard(CCopyFocusedNameModeEnum mode)
CFileData* file = (FocusedIndex < Dirs->Count) ? &Dirs->At(FocusedIndex) : &Files->At(FocusedIndex - Dirs->Count);
if (Is(ptDisk) || Is(ptZIPArchive) || Is(ptPluginFS) && mode == cfnmShort)
{
// For Unicode filenames, use wide path to preserve non-ANSI characters
if (file->UseWideName())
{
wchar_t buffW[2 * MAX_PATH];
// Convert path to wide
MultiByteToWideChar(CP_ACP, 0, buff, -1, buffW, 2 * MAX_PATH);
int l = (int)wcslen(buffW);
// Append wide filename (no AlterFileName for wide yet - TODO)
lstrcpynW(buffW + l, file->NameW.c_str(), 2 * MAX_PATH - l);
return CopyTextToClipboardW(buffW, -1, FALSE, NULL);
}

char fileName[MAX_PATH];
AlterFileName(fileName, file->Name, -1, Configuration.FileNameFormat, 0, FocusedIndex < Dirs->Count);
int l = (int)strlen(buff);
Expand Down
Loading