def mkdir(self,foldername,frominode): if not primitiveFunc.checkValidFilename(foldername): raise ex.exception_folder.invalidFilenameException(u"invalid filename @ mkdir") par=fd.getInstance(frominode,self.io) flist=par.getFile() flist.checkOut() if foldername in flist.kvm: raise ex.exception_folder.fileOperationException(u"folder already exist @ mkdir") nf=fd.getInstance(genGlobalUniqueName(),self.io) fmap=kvmap(None) fmap.checkOut() fmap.kvm[u"."]=(nf.filename,utils.timestamp.getTimestamp()) fmap.kvm[u".."]=(frominode,utils.timestamp.getTimestamp()) fmap.checkIn() nf.commitPatch(fmap) fmap=kvmap(None) fmap.setTimestamp(utils.timestamp.getTimestamp(flist.getTimestamp())) fmap.checkOut() fmap.kvm[foldername]=(nf.filename,flist.getRelativeTS(foldername)) fmap.checkIn() par.commitPatch(fmap)
def formatfs(self): # format the container. Attentez! No deletion is garanteed! nf=fd.getInstance(root_iNode_name,self.io) fmap=kvmap(None) fmap.checkOut() fmap.kvm[u"."]=(root_iNode_name,utils.timestamp.getTimestamp()) fmap.kvm[u".."]=(root_iNode_name,utils.timestamp.getTimestamp()) fmap.checkIn() nf.commitPatch(fmap)
def rm(self,foldername,frominode): # Attentez: this remove will remove the whole folder, no matter whether there's # anything in it. if not primitiveFunc.checkValidFilename(foldername): raise ex.exception_folder.invalidFilenameException(u"invalid filename @ mkdir") par=fd.getInstance(frominode,self.io) flist=par.getFile() flist.checkOut() if foldername not in flist.kvm: return fmap=kvmap(None) fmap.setTimestamp(utils.timestamp.getTimestamp(flist.getTimestamp())) fmap.checkOut() fmap.kvm[foldername]=(kvmap.REMOVE_SPECIFIED,flist.getRelativeTS(foldername)) fmap.checkIn() par.commitPatch(fmap)