File System
Last updated
// Check if a file extension is recognized
def isRecognizedFileType(filename) (
local extension = filename.split(".").last()
return file_types[extension] != null
)
// Get the description of a file type
def getFileTypeDescription(filename) (
local extension = filename.split(".").last()
local fileType = file_types[extension]
if fileType (
return fileType[2]
// Return the description (second element)
) else (
return "Unknown file type"
)
)
// Get applications that can open a file
def getCompatibleApps(filename) (
local extension = filename.split(".").last()
local fileType = file_types[extension]
if fileType and fileType[3] (
return fileType[3]
// Return the array of applications
) else (
return []
)
)
// Example usage
filename = "document.txt"
if isRecognizedFileType(filename) (
log "File type: " ++ getFileTypeDescription(filename)
apps = getCompatibleApps(filename)
if apps.len > 0 (
log "Can be opened with: " ++ apps.join(", ")
) else (
log "No compatible applications found"
)
)