1+ < html >
2+ < head >
3+ < meta http-equiv ="Content-Type " content ="text/html; charset=utf-8 " />
4+ < title > Ki docs: File</ title >
5+ < style type ="text/css ">
6+ a { text-decoration : none; }
7+ a : hover { text-decoration : underline; }
8+ th { background-color : # DDDDDD ; vertical-align : top; padding : 3px ; }
9+ td { width : 100% ; background-color : # EEEEEE ; vertical-align : top; padding : 3px ; }
10+ table { width : 100% ; border : 1px solid # 0; text-align : left; }
11+ section > table table td { width : 0 ; }
12+ </ style >
13+ < link rel ="stylesheet " href ="docs.css " type ="text/css " media ="screen " />
14+ </ head >
15+ < body >
16+ < header >
17+ < h1 > < a href ="./index.html "> docs</ a > » File</ h1 >
18+ < p > File class that subclasses < a href ="Entity.html "> Entity</ a > to represent some directory or file</ p >
19+
20+ </ header >
21+ < h3 > API Overview</ h3 >
22+ < ul >
23+ < li > Variables - Configurable values</ li >
24+ < ul >
25+ < li > < a href ="#behaviors "> behaviors</ a > </ li >
26+ </ ul >
27+ < li > Methods - API calls which can only be made on an object returned by a constructor</ li >
28+ < ul >
29+ < li > < a href ="#createEvent "> createEvent</ a > </ li >
30+ < li > < a href ="#getFileIcon "> getFileIcon</ a > </ li >
31+ < li > < a href ="#initialize "> initialize</ a > </ li >
32+ < li > < a href ="#moveToTrash "> moveToTrash</ a > </ li >
33+ < li > < a href ="#navigate "> navigate</ a > </ li >
34+ < li > < a href ="#open "> open</ a > </ li >
35+ < li > < a href ="#openInfoWindow "> openInfoWindow</ a > </ li >
36+ < li > < a href ="#openWith "> openWith</ a > </ li >
37+ < li > < a href ="#showFileSelectionModal "> showFileSelectionModal</ a > </ li >
38+ </ ul >
39+ </ ul >
40+ < h3 > API Documentation</ h3 >
41+ < h4 class ="documentation-section "> Variables</ h4 >
42+ < section id ="behaviors ">
43+ < a name ="//apple_ref/cpp/Variable/behaviors " class ="dashAnchor "> </ a >
44+ < h5 > < a href ="#behaviors "> behaviors</ a > </ h5 >
45+ < table >
46+ < tr >
47+ < th > Signature</ th >
48+ < td > < code > File.behaviors</ code > </ td >
49+ </ tr >
50+ < tr >
51+ < th > Type</ th >
52+ < td > Variable</ td >
53+ </ tr >
54+ < tr >
55+ < th > Description</ th >
56+ < td > < p > File < a href ="Entity.html#behaviors "> behaviors</ a > defined to invoke event handlers with the file path.</ p >
57+ </ td >
58+ </ tr >
59+ </ table >
60+ </ section >
61+ < h4 class ="documentation-section "> Methods</ h4 >
62+ < section id ="createEvent ">
63+ < a name ="//apple_ref/cpp/Method/createEvent " class ="dashAnchor "> </ a >
64+ < h5 > < a href ="#createEvent "> createEvent</ a > </ h5 >
65+ < table >
66+ < tr >
67+ < th > Signature</ th >
68+ < td > < code > File:createEvent(path)</ code > </ td >
69+ </ tr >
70+ < tr >
71+ < th > Type</ th >
72+ < td > Method</ td >
73+ </ tr >
74+ < tr >
75+ < th > Description</ th >
76+ < td > < p > Convenience method to create file events that share the similar behavior of allowing navigation before item selection</ p >
77+ < p > Parameters:</ p >
78+ < ul >
79+ < li > < code > path</ code > - The path of a file</ li >
80+ </ ul >
81+ < p > Returns:</ p >
82+ < ul >
83+ < li > An event handler function</ li >
84+ </ ul >
85+ </ td >
86+ </ tr >
87+ </ table >
88+ </ section >
89+ < section id ="getFileIcon ">
90+ < a name ="//apple_ref/cpp/Method/getFileIcon " class ="dashAnchor "> </ a >
91+ < h5 > < a href ="#getFileIcon "> getFileIcon</ a > </ h5 >
92+ < table >
93+ < tr >
94+ < th > Signature</ th >
95+ < td > < code > File:getFileIcon(path)</ code > </ td >
96+ </ tr >
97+ < tr >
98+ < th > Type</ th >
99+ < td > Method</ td >
100+ </ tr >
101+ < tr >
102+ < th > Description</ th >
103+ < td > < p > Retrieves an icon image for the given file path or returns nil if not found</ p >
104+ < p > Parameters:</ p >
105+ < ul >
106+ < li > < code > path</ code > - The path of a file</ li >
107+ </ ul >
108+ < p > Returns:</ p >
109+ < ul >
110+ < li > The file icon < a href ="http://www.hammerspoon.org/docs/hs.image.html "> < code > hs.image</ code > </ a > object</ li >
111+ </ ul >
112+ </ td >
113+ </ tr >
114+ </ table >
115+ </ section >
116+ < section id ="initialize ">
117+ < a name ="//apple_ref/cpp/Method/initialize " class ="dashAnchor "> </ a >
118+ < h5 > < a href ="#initialize "> initialize</ a > </ h5 >
119+ < table >
120+ < tr >
121+ < th > Signature</ th >
122+ < td > < code > File:initialize(path, shortcuts)</ code > </ td >
123+ </ tr >
124+ < tr >
125+ < th > Type</ th >
126+ < td > Method</ td >
127+ </ tr >
128+ < tr >
129+ < th > Description</ th >
130+ < td > < p > Initializes a new file instance with its path and custom shortcuts. By default, a cheatsheet and common shortcuts are initialized.</ p >
131+ < p > Parameters:</ p >
132+ < ul >
133+ < li > < code > path</ code > - The initial directory path</ li >
134+ < li > < code > shortcuts</ code > - The list of shortcuts containing keybindings and actions for the file entity</ li >
135+ </ ul >
136+ < p > Each < code > shortcut</ code > item should be a list with items at the following indices:</ p >
137+ < ul >
138+ < li > < code > 1</ code > - An optional table containing zero or more of the following keyboard modifiers: < code > "cmd"</ code > , < code > "alt"</ code > , < code > "shift"</ code > , < code > "ctrl"</ code > , < code > "fn"</ code > </ li >
139+ < li > < code > 2</ code > - The name of a keyboard key. String representations of keys can be found in < a href ="https://www.hammerspoon.org/docs/hs.keycodes.html#map "> < code > hs.keycodes.map</ code > </ a > .</ li >
140+ < li > < code > 3</ code > - The event handler that defines the action for when the shortcut is triggered</ li >
141+ < li > < code > 4</ code > - A table containing the metadata for the shortcut, also a list with items at the following indices:< ul >
142+ < li > < code > 1</ code > - The category name of the shortcut</ li >
143+ < li > < code > 2</ code > - A description of what the shortcut does</ li >
144+ </ ul >
145+ </ li >
146+ </ ul >
147+ < p > Returns:</ p >
148+ < ul >
149+ < li > None</ li >
150+ </ ul >
151+ </ td >
152+ </ tr >
153+ </ table >
154+ </ section >
155+ < section id ="moveToTrash ">
156+ < a name ="//apple_ref/cpp/Method/moveToTrash " class ="dashAnchor "> </ a >
157+ < h5 > < a href ="#moveToTrash "> moveToTrash</ a > </ h5 >
158+ < table >
159+ < tr >
160+ < th > Signature</ th >
161+ < td > < code > File:moveToTrash(path)</ code > </ td >
162+ </ tr >
163+ < tr >
164+ < th > Type</ th >
165+ < td > Method</ td >
166+ </ tr >
167+ < tr >
168+ < th > Description</ th >
169+ < td > < p > Moves a file or directory at the given path to the Trash. A dialog block alert opens to confirm before proceeding with the operation.</ p >
170+ < p > Parameters:</ p >
171+ < ul >
172+ < li > < code > path</ code > - the path of the target file to move to the trash</ li >
173+ </ ul >
174+ < p > Returns:</ p >
175+ < ul >
176+ < li > None</ li >
177+ </ ul >
178+ </ td >
179+ </ tr >
180+ </ table >
181+ </ section >
182+ < section id ="navigate ">
183+ < a name ="//apple_ref/cpp/Method/navigate " class ="dashAnchor "> </ a >
184+ < h5 > < a href ="#navigate "> navigate</ a > </ h5 >
185+ < table >
186+ < tr >
187+ < th > Signature</ th >
188+ < td > < code > File:navigate(path, handler)</ code > </ td >
189+ </ tr >
190+ < tr >
191+ < th > Type</ th >
192+ < td > Method</ td >
193+ </ tr >
194+ < tr >
195+ < th > Description</ th >
196+ < td > < p > Recursively navigates through parent and child directories until a selection is made</ p >
197+ < p > Parameters:</ p >
198+ < ul >
199+ < li > < code > path</ code > - the path of the target file</ li >
200+ < li > < code > handler</ code > - the selection callback handler function invoked with the following arguments:< ul >
201+ < li > < code > targetFilePath</ code > - the target path of the selected file</ li >
202+ </ ul >
203+ </ li >
204+ </ ul >
205+ < p > Returns:</ p >
206+ < ul >
207+ < li > None</ li >
208+ </ ul >
209+ </ td >
210+ </ tr >
211+ </ table >
212+ </ section >
213+ < section id ="open ">
214+ < a name ="//apple_ref/cpp/Method/open " class ="dashAnchor "> </ a >
215+ < h5 > < a href ="#open "> open</ a > </ h5 >
216+ < table >
217+ < tr >
218+ < th > Signature</ th >
219+ < td > < code > File:open(path)</ code > </ td >
220+ </ tr >
221+ < tr >
222+ < th > Type</ th >
223+ < td > Method</ td >
224+ </ tr >
225+ < tr >
226+ < th > Description</ th >
227+ < td > < p > Opens a file or directory at the given path</ p >
228+ < p > Parameters:</ p >
229+ < ul >
230+ < li > < code > path</ code > - the path of the target file to open</ li >
231+ </ ul >
232+ < p > Returns:</ p >
233+ < ul >
234+ < li > None</ li >
235+ </ ul >
236+ </ td >
237+ </ tr >
238+ </ table >
239+ </ section >
240+ < section id ="openInfoWindow ">
241+ < a name ="//apple_ref/cpp/Method/openInfoWindow " class ="dashAnchor "> </ a >
242+ < h5 > < a href ="#openInfoWindow "> openInfoWindow</ a > </ h5 >
243+ < table >
244+ < tr >
245+ < th > Signature</ th >
246+ < td > < code > File:openInfoWindow(path)</ code > </ td >
247+ </ tr >
248+ < tr >
249+ < th > Type</ th >
250+ < td > Method</ td >
251+ </ tr >
252+ < tr >
253+ < th > Description</ th >
254+ < td > < p > Opens a Finder information window for the file at < code > path</ code > </ p >
255+ < p > Parameters:</ p >
256+ < ul >
257+ < li > < code > path</ code > - the path of the target file</ li >
258+ </ ul >
259+ < p > Returns:</ p >
260+ < ul >
261+ < li > None</ li >
262+ </ ul >
263+ </ td >
264+ </ tr >
265+ </ table >
266+ </ section >
267+ < section id ="openWith ">
268+ < a name ="//apple_ref/cpp/Method/openWith " class ="dashAnchor "> </ a >
269+ < h5 > < a href ="#openWith "> openWith</ a > </ h5 >
270+ < table >
271+ < tr >
272+ < th > Signature</ th >
273+ < td > < code > File:openWith(path)</ code > </ td >
274+ </ tr >
275+ < tr >
276+ < th > Type</ th >
277+ < td > Method</ td >
278+ </ tr >
279+ < tr >
280+ < th > Description</ th >
281+ < td > < p > Opens a file or directory at the given path with a specified application and raises the application to the front</ p >
282+ < p > Parameters:</ p >
283+ < ul >
284+ < li > < code > path</ code > - the path of the target file to open</ li >
285+ </ ul >
286+ < p > Returns:</ p >
287+ < ul >
288+ < li > None</ li >
289+ </ ul >
290+ </ td >
291+ </ tr >
292+ </ table >
293+ </ section >
294+ < section id ="showFileSelectionModal ">
295+ < a name ="//apple_ref/cpp/Method/showFileSelectionModal " class ="dashAnchor "> </ a >
296+ < h5 > < a href ="#showFileSelectionModal "> showFileSelectionModal</ a > </ h5 >
297+ < table >
298+ < tr >
299+ < th > Signature</ th >
300+ < td > < code > File:showFileSelectionModal(path, handler)</ code > </ td >
301+ </ tr >
302+ < tr >
303+ < th > Type</ th >
304+ < td > Method</ td >
305+ </ tr >
306+ < tr >
307+ < th > Description</ th >
308+ < td > < p > Shows a selection modal with a list of files at a given path.</ p >
309+ < p > Parameters:</ p >
310+ < ul >
311+ < li > < code > path</ code > - the path of the directory that should have its file contents listed in the selection modal</ li >
312+ < li > < code > handler</ code > - the selection event handler function that takes in the following arguments:< ul >
313+ < li > < code > targetPath</ code > - the selected target path</ li >
314+ < li > < code > shouldTriggerAction</ code > - a boolean value to ensure the action is triggered</ li >
315+ </ ul >
316+ </ li >
317+ </ ul >
318+ < p > Returns:</ p >
319+ < ul >
320+ < li > A list of < a href ="https://www.hammerspoon.org/docs/hs.chooser.html#choices "> choice</ a > objects</ li >
321+ </ ul >
322+ </ td >
323+ </ tr >
324+ </ table >
325+ </ section >
326+ </ body >
327+ </ html >
0 commit comments