Skip to content

Commit

Permalink
#135 ディレクトリ作成対応 & #9 長さのチェックの為引数をフルパスに変更
Browse files Browse the repository at this point in the history
  • Loading branch information
yamahubuki committed Jan 13, 2020
1 parent ad7d9d7 commit 0c13708
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
9 changes: 7 additions & 2 deletions fileSystemManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import win32api
import re
import os
from enum import Enum

def GetFileSystemObject(letter):
Expand All @@ -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=[]
Expand Down
28 changes: 16 additions & 12 deletions tabObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit 0c13708

Please sign in to comment.