forked from iGio90/filemanager-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.lua
More file actions
55 lines (47 loc) · 1.34 KB
/
file.lua
File metadata and controls
55 lines (47 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
local micro = import('micro')
local config = import('micro/config')
local utils = dofile(config.ConfigDir .. '/plug/filemanager/utils.lua')
local icon_utils = dofile(config.ConfigDir .. '/plug/filemanager/icon.lua')
local icons = icon_utils.Icons()
local filepath = import('path/filepath')
local Entry = dofile(config.ConfigDir .. '/plug/filemanager/entry.lua')
--local Entry = require('entry')
---@class File : Entry
local File = setmetatable({}, { __index = Entry })
File.__index = File
---@param name string
---@param path string
---@param parent Entry
---@return Entry:File--todo
function File:new(name, path, parent)
local entry = Entry:new(
name,
icon_utils.GetIcon(name),
path,
parent
)
local instance = setmetatable(entry, File)
return instance
end
--todo
function File:is_dir()
return false
end
-- Builds and returns the string representation of the file
-- The string is made up of an icon, the file name, and a slash if it's a directory
function File:get_content(offset)
if not self.content or true then
local content = self.icon .. ' ' .. self.name
if offset then
content = string.rep(' ', 2 * offset) .. content
end
self.content = content
end
return self.content
end
function File:set_file_name(name)
-- Since update, the content is not up-to-date
self.content = nil
self.name = name
end
return File