Exemple #1
0
// From the parent inode, consult the vfilename and return its corresponding filename
// With any error, the string returned will be "".
// However, when the file does not exist, error WILL BE nil
func lookUp(inode string, vfilename string, io outapi.Outapi) (string, error) {
	if !CheckValidFilename(vfilename) {
		return "", exception.EX_INVALID_FILENAME
	}
	var meta, file, err = io.Get(GenFileName(inode, vfilename))
	if file == nil {
		return "", err
	}
	if meta == nil || meta[META_INODE_TYPE] != META_INODE_TYPE_FOLDER {
		return "", err
	}
	if fileNnode, ok := file.(*filetype.Nnode); !ok {
		Secretary.Warn("kernel.filesystem::lookUp", "File "+GenFileName(inode, vfilename)+" has a invalid filetype.")
		return "", nil
	} else {
		//fmt.Println("+++++++++++++++++++++", GenFileName(inode, vfilename), "=", fileNnode.DesName)
		return fileNnode.DesName, nil
	}
}
Exemple #2
0
// use outapi::Outapi.GenerateUniqueID() as identifier
// a nil may be returned indicating error
func GetFs(io outapi.Outapi) *Fs {
	var id = io.GenerateUniqueID()

	fsMapLock.RLock()
	if elem, ok := globalFsMap[id]; ok {
		fsMapLock.RUnlock()
		return elem
	}
	fsMapLock.RUnlock()
	fsMapLock.Lock()
	defer fsMapLock.Unlock()

	if elem, ok := globalFsMap[id]; ok {
		return elem
	}
	var ret = newFs(io)
	globalFsMap[id] = ret

	return ret
}