diff --git a/fileSystemManager.py b/fileSystemManager.py index c652485..34876d6 100644 --- a/fileSystemManager.py +++ b/fileSystemManager.py @@ -6,6 +6,7 @@ import win32api import re +import os from enum import Enum def GetFileSystemObject(letter): @@ -24,8 +25,12 @@ def GetFileSystemObject(letter): #end keyError return cls() -def ValidationObjectName(s): - """ファイルやディレクトリの名前sに何らかの問題があればその内容を返す""" +def ValidationObjectName(path): + """ + ファイルやディレクトリの名前pathに何らかの問題があればその内容を返す + sはフルパス + """ + s=os.path.split(path)[1] #使用できない文字の確認 ngString=[] diff --git a/tabObjects.py b/tabObjects.py index c99037b..782440d 100644 --- a/tabObjects.py +++ b/tabObjects.py @@ -324,17 +324,17 @@ def OnLabelEditEnd(self,evt): if evt.IsEditCancelled(): #ユーザによる編集キャンセル return e=self.hListCtrl.GetEditControl() - print(fileSystemManager.ValidationObjectName(e.GetLineText(0))) - if fileSystemManager.ValidationObjectName(e.GetLineText(0)): - dialog(_("エラー"),fileSystemManager.ValidationObjectName(e.GetLineText(0))) - evt.Veto() - return f=self.listObject.GetElement(self.hListCtrl.GetFocusedItem()) if isinstance(f,browsableObjects.File): - inst={"operation": "rename", "files": [f.fullpath], "to": [f.directory+"\\"+e.GetLineText(0)]} + newName=f.directory+"\\"+e.GetLineText(0) else: - inst={"operation": "rename", "files": [f.fullpath], "to": [e.GetLineText(0)]} + newName=e.GetLineText(0) #end ファイルかドライブか + if fileSystemManager.ValidationObjectName(newName): + dialog(_("エラー"),fileSystemManager.ValidationObjectName(e.GetLineText(0))) + evt.Veto() + return + inst={"operation": "rename", "files": [f.fullpath], "to": [newName]} op=fileOperator.FileOperator(inst) ret=op.Execute() if op.CheckSucceeded()==0: @@ -403,20 +403,24 @@ def SortCycleAd(self): self.hListCtrl.DeleteAllItems() self.UpdateListContent(self.listObject.GetItems()) - def UpdateFilelist(self,silence=False): + def UpdateFilelist(self,silence=False,cursorTargetName=""): """同じフォルダで、ファイルとフォルダ情報を最新に更新する。""" if silence==True: globalVars.app.say(_("更新")) - item=self.listObject.GetElement(self.GetFocusedItem()) + if cursorTargetName=="": + item=self.listObject.GetElement(self.GetFocusedItem()) result=self.listObject.Update() - cursor=self.listObject.Search(item.basename) if result != errorCodes.OK: return errorCodes.FILE_NOT_FOUND #アクセス負荷など + if cursorTargetName=="": + cursor=self.listObject.Search(item.basename,0) + else: + cursor=self.listObject.Search(cursorTargetName,0) self.Update(self.listObject,cursor) def MakeDirectory(self,newdir): dir=self.listObject.rootDirectory - if fileSystemManager.ValidationObjectName(newdir): + if fileSystemManager.ValidationObjectName(dir+"\\"+newdir): dialog(_("エラー"),fileSystemManager.ValidationObjectName(newdir)) return dest=os.path.join(dir,newdir) @@ -427,7 +431,7 @@ def MakeDirectory(self,newdir): dialog(_("エラー"),_("フォルダを作成できません。")) return #end error - self.UpdateFilelist(silence=True) + self.UpdateFilelist(silence=True,cursorTargetName=newdir) def MakeShortcut(self,option): prm="" diff --git a/views/main.py b/views/main.py index 1a1fbd6..2250c59 100644 --- a/views/main.py +++ b/views/main.py @@ -303,7 +303,7 @@ def OnMenuSelect(self,event): d.Initialize() ret=d.Show() if ret==wx.ID_CANCEL: return - self.parent.activeTab.MakeDirectory(self.parent.activeTab.listObject.rootDirectory+"\\"+d.GetValue()) + self.parent.activeTab.MakeDirectory(d.GetValue()) d.Destroy() return if selected==menuItemsStore.getRef("FILE_FILEOPTEST"):