mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
FIX: Show error when cannot create a new file.
This commit is contained in:
parent
c20637aecf
commit
edba9d8663
2 changed files with 22 additions and 14 deletions
|
|
@ -111,6 +111,8 @@ resourcestring
|
|||
rsMsgCanNotCopyMoveItSelf = 'You can not copy/move a file "%s" to itself!';
|
||||
rsMsgTabRenameCaption = 'Rename tab';
|
||||
rsMsgTabRenamePrompt = 'New tab name:';
|
||||
rsMsgErrCreateFileDirectoryExists = 'There already exists a directory named "%s".';
|
||||
|
||||
// for context menu
|
||||
rsMnuActions = 'Actions';
|
||||
rsMnuView = 'View';
|
||||
|
|
|
|||
|
|
@ -2019,8 +2019,9 @@ end;
|
|||
procedure TMainCommands.cm_EditNew(Param: String='');
|
||||
var
|
||||
sNewFile: String;
|
||||
hFile: Integer = 0;
|
||||
hFile: System.THandle = 0;
|
||||
aFile: TFile;
|
||||
Attrs: TFileAttrs;
|
||||
begin
|
||||
frmMain.ActiveFrame.ExecuteCommand('cm_EditNew', param);
|
||||
|
||||
|
|
@ -2046,21 +2047,26 @@ begin
|
|||
if ExtractFilePath(sNewFile) = '' then
|
||||
sNewFile:= ActiveFrame.CurrentPath + sNewFile;
|
||||
|
||||
if not mbFileExists(sNewFile) then
|
||||
try
|
||||
hFile:= mbFileCreate(sNewFile);
|
||||
finally
|
||||
if hFile > 0 then
|
||||
FileClose(hFile);
|
||||
Attrs := mbFileGetAttr(sNewFile);
|
||||
if Attrs = faInvalidAttributes then
|
||||
begin
|
||||
hFile := mbFileCreate(sNewFile);
|
||||
if hFile = feInvalidHandle then
|
||||
begin
|
||||
MessageDlg(rsMsgErrECreate, mbSysErrorMessage(GetLastOSError), mtWarning, [mbOK], 0);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
try
|
||||
ShowEditorByGlob(sNewFile);
|
||||
|
||||
finally
|
||||
frameLeft.Reload;
|
||||
frameRight.Reload;
|
||||
FileClose(hFile);
|
||||
ActiveFrame.FileSource.Reload(ExtractFilePath(sNewFile));
|
||||
end
|
||||
else if FPS_ISDIR(Attrs) then
|
||||
begin
|
||||
MessageDlg(rsMsgErrECreate, Format(rsMsgErrCreateFileDirectoryExists,
|
||||
[ExtractFileName(sNewFile)]), mtWarning, [mbOK], 0);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
ShowEditorByGlob(sNewFile);
|
||||
end
|
||||
else
|
||||
msgWarning(rsMsgNotImplemented);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue