source: cprs/branches/tmg-cprs/m_files/TMGIOUTL.m@ 1806

Last change on this file since 1806 was 796, checked in by Kevin Toppenberg, 14 years ago

Initial upload

File size: 22.6 KB
Line 
1TMGIOUTL ;TMG/kst/IO Utilities ;03/25/06
2 ;;1.0;TMG-LIB;**1**;07/12/05
3
4 ;"TMG IO UTILITIES
5 ;"Kevin Toppenberg MD
6 ;"GNU General Public License (GPL) applies
7 ;"7-12-2005
8
9 ;"=======================================================================
10 ;" API -- Public Functions.
11 ;"=======================================================================
12 ;"$$FNameExtract^TMGIOUTL(FullNamePath,NodeDiv)
13 ;"$$PathExtract^TMGIOUTL(FullNamePath,NodeDiv)
14 ;"$$UpPath^TMGIOUTL(Path,NodeDiv) -- return a path that is one step up from current path
15 ;"SplitFNamePath^TMGIOUTL(FullNamePath,OutName,OutPath,NodeDiv)
16 ;"$$GetFName^TMGIOUTL(Msg,DefPath,DefFName,NodeDiv,OutPath,OutName,Prompt)
17 ;"$$GetDirName(Msg,DefPath,NodeDiv,OutPath,Prompt) -- query user for a directory name
18 ;"$$IsDir^TMGIOUTL(Path) ;DEPRECIATED .. moved to ^TMGKERNL
19 ;"$$Move^TMGIOUTL(Source,Dest) ;DEPRECIATED .. moved to ^TMGKERNL
20 ;"$$FileExists^TMGIOUTL(FullNamePath)
21 ;"$$Dos2Unix^TMGIOUTL(FullNamePath) ;DEPRECIATED .. moved to ^TMGKERNL
22 ;"$$WP2HFS^TMGIOUTL(GlobalP,path,filename)
23 ;"$$WP2HFSfp^TMGIOUTL(GlobalP,pathfilename)
24 ;"$$HFS2WP^TMGIOUTL(path,filename,GlobalP)
25 ;"$$HFS2WPfp^TMGIOUTL(pathfilename,GlobalP)
26 ;"$$DelFile^TMGIOUTL(pathfilename)
27 ;"$$EnsureTrailDiv^TMGIOUTL(path)
28
29 ;"=======================================================================
30 ;"Dependancies
31 ;"TMGUSRIF for showing dialogs.
32 ;"TMGDEBUG
33 ;"TMGSTUTL
34 ;"TMGMISC
35 ;"=======================================================================
36
37 ;"=======================================================================
38
39FNameExtract(FullNamePath,NodeDiv)
40 ;"SCOPE: Public
41 ;"Purpose: to extract a file name from a full path+name string
42 ;"Input: FullNamePath: String to process.
43 ;" e.g.: "/tmp/myfilename.txt"
44 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
45 ;" if not supplied, then default value is "/"
46 ;"Result: the filename, or "" if not found
47 ;" e.g.: "myfilename.txt"
48
49 new OutPath,OutName
50 do SplitFNamePath(.FullNamePath,.OutPath,.OutName,.NodeDiv)
51 quit $get(OutName)
52
53
54PathExtract(FullNamePath,NodeDiv)
55 ;"SCOPE: Public
56 ;"Purpose: to extract a file name from a full path+name string
57 ;"Input: FullNamePath: String to process.
58 ;" e.g.: "/usr/local/myfilename.txt"
59 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
60 ;" if not supplied, then default value is "/"
61 ;"Result: the path, or "" if not found
62 ;" e.g.: "/usr/local/"
63
64 new OutPath,OutName
65 do SplitFNamePath(.FullNamePath,.OutPath,.OutName,.NodeDiv)
66 quit $get(OutPath)
67
68UpPath(Path,NodeDiv)
69 ;"SCOPE: Public
70 ;"Purpose: To return a path that is one step up from current path
71 ;"Input: Path -- NOTE: **MUST NOT** have a file name
72 ;" e.g. RIGHT --> '/var/local/'
73 ;" WRONG --> '/var/MyFile.txt' <-- 'MyFile.txt' would be treated as path node
74 ;" '/var/MyFile.txt' = '/var/MyFile.txt/' ==> UP ==> '/var/'
75 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
76 ;" if not supplied, then default value is "/"
77 ;"Results: Returns resulting path. E.g. '/var/local/' --> '/var/'
78 ;" Note: '/' --> '/' (i.e. can't go higher than root)
79 set NodeDiv=$get(NodeDiv,"/")
80 new tempPath set tempPath=$$EnsureTrailDiv($get(Path),NodeDiv)
81 new result set result=NodeDiv
82 if tempPath'=NodeDiv do
83 . set result=$piece(tempPath,"/",1,$length(tempPath,"/")-2)_NodeDiv
84 else set result=NodeDiv
85 quit result
86
87ExtExtract(FullNamePath,NodeDiv)
88 ;"Purpose: to return the extension of the file name from full path+name string
89 ;" This will be everything after the last '.'
90 ;"Input: FullNamePath: String to process.
91 ;" e.g.: "/usr/local/myfilename.txt"
92 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
93 ;" if not supplied, then default value is "/"
94 ;"Result: the extension or "" if not found
95 ;" e.g.: "txt" (doesn't include '.'
96
97 new result
98 set result=$piece(FullNamePath,".",$length(FullNamePath,"."))
99 quit result
100
101SplitFNamePath(FullNamePath,OutPath,OutName,NodeDiv)
102 ;"SCOPE: Public
103 ;"Purpose: Take FullNamePath, and split into name and path.
104 ;"Input: FullNamePath: String to process.
105 ;" e.g.: "/tmp/myfilename.txt"
106 ;" NOTICE: IF PASSED BY REFERENCE, WILL BE CHANGED TO FILENAME!
107 ;" OutName: MUST BE PASSED BY REFERENCE. This is an OUT parameter
108 ;" OutPath: MUST BE PASSED BY REFERENCE. This is an OUT parameter
109 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
110 ;" if not supplied, then default value is "/"
111 ;"Output: The resulting file name is put into OutName,
112 ;" e.g.: "myfilename.txt"
113 ;" and the path is put into OutPath.
114 ;" e.g.: "/tmp/"
115 ;"Result: None.
116
117 set OutPath=""
118 set OutName=""
119 new PathNode
120 set NodeDiv=$get(NodeDiv,"/")
121 set FullNamePath=$get(FullNamePath)
122SPN1
123 if (FullNamePath[NodeDiv)=0 set OutName=FullNamePath goto SPNDone
124 set PathNode=$piece(FullNamePath,NodeDiv,1)
125 set OutPath=OutPath_PathNode_NodeDiv
126 set $piece(FullNamePath,NodeDiv,1)=""
127 set FullNamePath=$extract(FullNamePath,2,255)
128 goto SPN1
129
130SPNDone
131 quit
132
133
134GetFName(Msg,DefPath,DefFName,NodeDiv,OutPath,OutName,Prompt)
135 ;"SCOPE: PUBLIC
136 ;"Purpose: To query the user, to get a filename back
137 ;" Supplies optional directory listing.
138 ;"Input: Msg. [OPTIONAL] A message to show user prior to name prompt.
139 ;" May contain "\n" character for line wrapping.
140 ;" DefPath: [OPTIONAL] The default path to offer user.
141 ;" DefFName:[OPTIONAL] The default filename to offer user.
142 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
143 ;" if not supplied, then default value is "/"
144 ;" OutPath: [OPTIONAL] Pass by reference, filled with selected path
145 ;" //no --> Note: Will return like this: '/home/test' not '/home/test/'
146 ;" (6-5-05: I think this because $$FTG^%ZISH wants the path like this)
147 ;" OutName: [OPTIONAL] Pass by reference, filled with selected name
148 ;" Prompt: [OPTIONAL] Prompt for user to enter filename/directory name
149 ;"Result: returns user specified filename (with path), or "" if aborted
150
151 ;"5/16/09 -- Code changed to use newer, more GUI, file browser.
152 new Option
153 new result set result=""
154 set Option("MSG")=$get(Msg)
155 set Option("PATH")=$get(DefPath)
156 set Option("NAME")=$get(DefFName)
157 set Option("NodeDiv")=$get(NodeDiv)
158 set Option("PROMPT")=$get(Prompt)
159 set result=$$FBrowse^TMGIOUT2(.Option,.OutPath,.OutName)
160 quit result
161
162 ;"------- older code below ---------------
163 if $get(TMGDEBUG)>0 do DebugEntry^TMGDEBUG(.DBIndent,"GetFName^TMGIOUTL")
164
165 set Prompt=$get(Prompt,"Enter File Name (? for help): ")
166 if $data(Msg) do
167 . if $get(TMGDEBUG)>0 do DebugMsg^TMGDEBUG(DBIndent,"Calling PopupBox")
168 . do PopupBox^TMGUSRIF("Message:",$get(Msg)_"\nEnter ? for help.")
169
170 set DefFName=$get(DefFName)
171 if $get(NodeDiv)="" kill NodeDiv
172 set NodeDiv=$get(NodeDiv,"/")
173 set DefPath=$get(DefPath)
174 new StackCaller set StackCaller=$$Caller^TMGMISC
175 if DefPath="" set DefPath=$get(^TMG("TMP","SETTINGS","GetFName",StackCaller)) ;"Default to the path used last time by caller
176 if DefPath="" set DefPath=NodeDiv
177 set OutPath=$get(OutPath)
178 set OutName=$get(OutName)
179 new UserName
180 new result set result=""
181 new loop set loop=0
182
183 if $$IsDir^TMGKERNL(DefPath)=0 do
184 . ;"write "Default directory ["_DefPath_"] doesn't exist.",!
185 . set DefPath=NodeDiv
186
187GFN1 write Prompt ;"hello
188 if $extract(DefPath,$length(DefPath))'=NodeDiv do
189 . set DefPath=DefPath_NodeDiv
190 write DefPath_DefFName,""
191 set UserName=$$Read^TMGUSRIF("rt",$get(DTIME,3600),,DefPath_DefFName) write !
192 set UserName=$$Trim^TMGSTUTL(UserName)
193
194 if (UserName["..") do goto GFN1
195 . new temp1
196 . ;"anything missing on this line? Was blank...
197 . if ($extract(DefPath,$length(DefPath))=NodeDiv)&(DefPath'="/") do
198 . set DefPath=$extract(DefPath,1,$length(DefPath)-1)
199 . do SplitFNamePath(DefPath,.DefPath,.temp,1)
200 else if UserName="" do goto GFNDone
201 . set OutPath=DefPath
202 . set OutName=DefFName
203 . set result=DefPath_DefFName
204 else if ($$UP^XLFSTR(UserName)["??") do goto GFN1
205 . new TMGMask,UserMask
206 . set UserMask=$piece(UserName,"?? ",2)
207 . if UserMask="" set UserMask=$piece(UserName,"?? ",2)
208 . if UserMask="" set UserMask="*"
209 . set TMGMask(UserMask)=""
210 . new TMGFiles
211 . if $$IsDir^TMGKERNL(DefPath)=0 write "?? invalid directory",! quit
212 . if $$LIST^%ZISH(DefPath,"TMGMask","TMGFiles")=1 do
213 . . write "Directory Listing",!
214 . . write "-----------------",!
215 . . new col set col=3
216 . . new index set index=""
217 . . for set index=$order(TMGFiles(index)) quit:(index)="" do
218 . . . set col=(col+1)#4
219 . . . write ?(col*20)+1," "
220 . . . new testDir set testDir=$$EnsureTrailDiv(DefPath,NodeDiv)
221 . . . set testDir=testDir_index
222 . . . if $$IsDir^TMGKERNL(testDir) write "<",index,">"
223 . . . else write index
224 . . . if col=3 write !
225 . . write !
226 else if UserName["^" do goto GFNDone
227 . set result=""
228 . set OutPath=""
229 . set OutName=""
230 else if UserName["?" do goto GFN1
231 . write " Current directory: [",DefPath,"]",!
232 . write " Default file name: [",DefFName,"]",!
233 . write " Example input: ",NodeDiv,"Data",NodeDiv,"Office",NodeDiv,"myfile.txt",!
234 . write " DELETE (with backspace) parts of path not wanted.",!
235 . write " Enter ^ to abort",!
236 . write " Enter ?? for directory listing (?? a* to show files starting with a)",!
237 . write " Enter .. to move up one directory level",!
238 . write " NOTE: If a partial name is entered then [ENTER] or [TAB], it will be autofinished.",!
239 else if $extract(UserName,$length(UserName))=NodeDiv do goto GFN1
240 . new tempPath set tempPath=DefPath
241 . if $extract(UserName,1,1)=NodeDiv set DefPath=""
242 . if $$IsDir^TMGKERNL(DefPath_UserName) set DefPath=DefPath_UserName
243 . else write "?? invalid directory",! set DefPath=tempPath
244 else for do quit:(loop'=1)
245 . if loop=0 do
246 . . if $extract(UserName,1,1)=NodeDiv do SplitFNamePath(UserName,.DefPath,.UserName)
247 . . set OutPath=DefPath
248 . . set OutName=UserName
249 . . set result=OutPath_OutName
250 . else set loop=0
251 . if $$IsDir^TMGKERNL(result) do quit
252 . . set DefPath=result
253 . . set DefName=""
254 . . set result=""
255 . . do CUU^TMGTERM(1) ;"cursor up 1 VT100 esc sequence.
256 . if result["*" do
257 . . set result=$$PickOneFile(result)
258 . if '$$FileExists(result) do
259 . . new tempresult set tempresult=result
260 . . set result=$$PickOneFile(result_"*")
261 . . if result="^" set loop=0 quit
262 . . if result'="" set loop=1 quit
263 . . new UseAnyway
264 . . write !,"File name """,tempresult,""" doesn't exist.",!
265 . . read "Use name anyway? NO// ",UseAnyway:$get(DTIME,3600),!
266 . . set UseAnyway=$$UP^XLFSTR(UseAnyway)
267 . . if '(UseAnyway["Y") set result=""
268 . . else set result=tempresult
269
270 if result="" goto GFN1
271
272GFNDone
273 if (result'=UserName)&(UserName'="^") do
274 . write "Using file: ",result,!
275
276 do SplitFNamePath(result,.OutPath,.OutName,NodeDiv)
277 set ^TMG("TMP","SETTINGS","GetFName",StackCaller)=OutPath ;"store for future use.
278 quit result
279
280
281GetDirName(Msg,DefPath,NodeDiv,Prompt)
282 ;"SCOPE: PUBLIC
283 ;"Purpose: To query the user, to get a directory name back
284 ;"Input: Msg. [OPTIONAL] A message to show user prior to name prompt.
285 ;" May contain "\n" character for line wrapping.
286 ;" DefPath: [OPTIONAL] The default path to offer user.
287 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
288 ;" if not supplied, then default value is "/"
289 ;" Prompt: [OPTIONAL] Prompt for user to enter filename/directory name
290 ;"Result: returns user specified filename (with path), or "" if aborted
291 ;
292 new Option
293 new result set result=""
294 set Option("MSG")=$get(Msg)
295 set Option("PATH")=$get(DefPath)
296 set Option("NodeDiv")=$get(NodeDiv)
297 set Option("PROMPT")=$get(Prompt)
298 set Option("SELECT DIR")=1
299 set result=$$FBrowse^TMGIOUT2(.Option)
300 quit result
301
302
303IsDir(Path)
304 ;"Purpose: To determine if Path is a path to a directory (i.e. are there sub files)
305 ;"Input: Path to test, e.g. "/home/user" or "/home/user/"
306 ;"Result: 1 if there are files in path, 0 otherwise
307 ;"Note: if Path is a valid path to a directory, but there are no files in directory, 0 returned.
308
309
310 ;"Moved to ^TMGKERNL
311 quit $$IsDir^TMGKERNL(.Path)
312
313
314Move(Source,Dest)
315 ;"Purpose to provide a shell for the Linux command 'mv'
316 ;" This can serve to move or rename a file
317 ;"Note: a platform independant version of the this could be constructed later...
318 ;"Result: 0 if no error; >0 if error
319 ;"Notice!!!! The return code here is DIFFERENT from usual
320
321 ;"Moved to ^TMGKERNL
322 quit $$Move^TMGKERNL(.Source,.Dest)
323
324
325FileExists(FullNamePath)
326 ;"To determine if file exists.
327 ;"Input: FullNamePath -- the full name and path of file to test, e.g. "/tmp/myfiles/a/test.txt"
328 ;"Results: 1 if file exists (and is unique), 0 if not
329 ;"Note: If FullNamePath indicates a directory, then 0 is returned.
330 ;" Note if FullNamePath contains a * pattern, that would cause multiple
331 ;" files to be returned, then filename is not unique, and function
332 ;" will RETURN THAT IT IS NOT A (unique) FILE
333
334 new JustName,JustPath
335 new TMGMask
336 new TMGFiles
337 new result set result=0
338
339 do SplitFNamePath(FullNamePath,.JustPath,.JustName)
340
341 set TMGMask(JustName)=""
342 if $$LIST^%ZISH(JustPath,"TMGMask","TMGFiles")=1 do
343 . if $$ListCt^TMGMISC("TMGFiles")=1 do
344 . . set result='$$IsDir^TMGKERNL(FullNamePath)
345
346 quit result
347
348
349PickOneFile(PartNamePath)
350 ;"To take a name like "MyFil*", and display all matches and allow user to pick one
351 ;"Input: PartNamePath -- the partial name and path of file to test, e.g. "/tmp/myfiles/a/tes*"
352 ;"Results: The FullNamePath of the chosen file (or "" if none, or canceled)
353 ;" 12-14-05, if user enters "^", this is returned.
354
355 new JustName,JustPath
356 new TMGMask
357 new TMGFiles
358 new result set result=""
359
360 do SplitFNamePath(PartNamePath,.JustPath,.JustName)
361
362 set TMGMask(JustName)=""
363 if $$LIST^%ZISH(JustPath,"TMGMask","TMGFiles")=1 do
364 . new count set count=$$ListCt^TMGMISC("TMGFiles")
365 . if count=1 set result=$order(TMGFiles("")) quit
366 . write count," matches to ",PartNamePath," found. Pick one:",!
367 . new part,fName,Num
368 . set fName=$order(TMGFiles(""))
369 . set Num=1
370 . set part=1
371 . if fName'="" for do quit:(fName="")!(result="^")
372 . . write " ",Num,". ",JustPath,fName
373 . . if $$IsDir^TMGKERNL(JustPath_fName) write "/"
374 . . write !
375 . . set TMGFiles(Num)=fName
376 . . set fName=$order(TMGFiles(fName))
377 . . if (part=10)!(fName="") do
378 . . . new choice
379 . . . set part=1
380 . . . write "Choose file (1-",Num,"), '^' to cancel, or [Enter] to continue: "
381 . . . read choice:$get(DTIME,3600),!!
382 . . . if choice="^" set fName="",result="^" quit
383 . . . if (+choice>0)&(+choice<Num+1) do
384 . . . . set result=$get(TMGFiles(+choice))
385 . . . . set fName=""
386 . . set part=part+1
387 . . set Num=Num+1
388
389 if result'="" do
390 . if result'="^" set result=JustPath_result
391 else do
392 . write "(No file selected.)",!
393
394 quit result
395
396
397Dos2Unix(FullNamePath)
398 ;"Purpose: To execute the unix command Dos2Unix on filename path
399 ;"FullNamePath: The filename to act on.
400 ;"Result: 0 if no error; >0 if error
401 ;"Notice!!!! The return code here is DIFFERENT from usual
402
403 ;"Moved to ^TMGKERNL
404 quit $$Dos2Unix^TMGKERNL(FullNamePath)
405
406
407WP2HFS(GlobalP,path,filename)
408 ;"Purpose: To write a WP field to a Host-File-System file
409 ;"Input: GlobalP -- The reference to the header node (e.g. ^TMG(22702,99,1) in example below)
410 ;" path: for the output file, the path up to, but not including, the filename
411 ;" filename -- the filename to save to in the host file system. If file already exists, it will be overwritten.
412 ;"Note: The format of a WP field is as follows:
413 ;" e.g. ^TMG(22702,99,1,0) = ^^4^4^3050118^
414 ;" ^TMG(22702,99,1,1,0) = Here is the first line of text
415 ;" ^TMG(22702,99,1,2,0) = And here is another line
416 ;" ^TMG(22702,99,1,3,0) =
417 ;" ^TMG(22702,99,1,4,0) = And here is a final line
418 ;" And the format of the 0 node is: ^^<line count>^<linecount>^<fmdate>^^
419 ;"Result: 0 if failure, 1 if success
420 ;"Assumptions: That GlobalP is a valid reference to a WP field
421
422 new result set result=0 ;"default to failure
423
424 if $data(GlobalP)&($data(path))&($data(filename)) do
425 . new TMGWP
426 . merge TMGWP=@GlobalP
427 . set result=$$GTF^%ZISH("TMGWP(1,0)",1,path,filename)
428
429 quit result
430
431WP2HFSfp(GlobalP,pathfilename)
432 ;"Purpose: To provide an interface to WP2HFS for cases when filename is not already separated from path
433 ;"Result: 0 if failure, 1 if success
434
435 new path,filename,result
436
437 do SplitFNamePath(.pathfilename,.path,.filename)
438 set result=$$WP2HFS(.GlobalP,.path,.filename)
439 quit result
440
441
442HFS2WP(path,filename,GlobalP)
443 ;"Purpose: To read a WP field from a Host-File-System file
444 ;"Input: path: for the output file, the path up to, but not including, the filename
445 ;" filename -- the filename to save to in the host file system. If file already exists, it will be overwritten.
446 ;" GlobalP -- The reference to the header node (e.g. ^TMG(22702,99,1) in example below)
447 ;"Note: The format of a WP field is as follows:
448 ;" e.g. ^TMG(22702,99,1,0) = ^^4^4^3050118^
449 ;" ^TMG(22702,99,1,1,0) = Here is the first line of text
450 ;" ^TMG(22702,99,1,2,0) = And here is another line
451 ;" ^TMG(22702,99,1,3,0) =
452 ;" ^TMG(22702,99,1,4,0) = And here is a final line
453 ;" And the format of the 0 node is: ^^<line count>^<linecount>^<fmdate>^^
454 ;"Result: 0 if failure, 1 if success
455 ;"Assumptions: That GlobalP is a valid reference to a WP field
456
457 new result set result=0 ;"default to failure
458
459 if $data(GlobalP)&($data(path))&($data(filename)) do
460 . new TMGWP,WP
461 . set result=$$FTG^%ZISH(path,filename,"TMGWP(1,0)",1)
462 . ;"zwr TMGWP(*)
463 . ;"new temp read "press enter to continue",temp:$get(DTIME,3600),!
464 . if result=0 quit
465 . ;"Scan for overflow nodes, and integrate into main body
466 . new i set i=$order(TMGWP(""))
467 . if i'="" for do quit:(i="")
468 . . if $data(TMGWP(i,"OVF")) do
469 . . . new j set j=$order(TMGWP(i,"OVF",""))
470 . . . if j'="" for do quit:(j="")
471 . . . . new n set n=i+(j/10)
472 . . . . set TMGWP(n,0)=TMGWP(i,"OVF",j)
473 . . . . set j=$order(TMGWP(i,"OVF",j))
474 . . . kill TMGWP(i,"OVF")
475 . . set i=$order(TMGWP(i))
476 . ;"Now copy into another variable, renumbering lines (in case there were overflow lines)
477 . set i=$order(TMGWP(""))
478 . set j=0
479 . if i'="" for do quit:(i="")
480 . . set j=j+1
481 . . set WP(j,0)=TMGWP(i,0)
482 . . set i=$order(TMGWP(i))
483 . ;"now create a header node
484 . do NOW^%DTC ;"returns result in X
485 . set WP(0)="^^"_j_"^"_j_"^"_X_"^^"
486 . ;"now put WP into global reference.
487 . ;"zwr WP(*)
488 . ;"new temp read "press enter to continue",temp:$get(DTIME,3600),!
489 . kill @GlobalP
490 . merge @GlobalP=WP
491
492 quit result
493
494
495HFS2WPfp(pathfilename,GlobalP)
496 ;"Purpose: To provide an interface to HFS2WP for cases when filename is not already separated from path
497 ;"Result: 0 if failure, 1 if success
498
499 new path,filename,result
500
501 do SplitFNamePath(.pathfilename,.path,.filename)
502 set result=$$HFS2WP(.path,.filename,.GlobalP)
503 quit result
504
505
506DelFile(pathfilename)
507 ;"Purpose: to delete one file on host file system
508 ;"Results: returns 1 if success, 0 if failure
509 ;"Note: 2/22/2006 -- if deletion is blocked by OS, then 1 may be returns but file is not deleted.
510
511 new path,filename,result
512 new TMGFile
513
514 do SplitFNamePath(.pathfilename,.path,.filename)
515 set TMGFile(filename)=""
516 set result=$$DEL^%ZISH(path,"TMGFile")
517
518 quit result
519
520
521EnsureTrailDiv(Path,NodeDiv)
522 ;"Purpose: to ensure that a path ends with a node divider.
523 ;" e.g. /var/local --> /var/local/
524 ;" and /var/local/ --> /var/local/
525 ;"Input: Path -- the path to convert
526 ;" NodeDiv: [OPTIONAL] -- the character that separates folders (e.g. "/")
527 ;" if not supplied, then default value is "/"
528 ;"Result: the converted/verified path.
529 ;
530 set Path=$get(Path)
531 set NodeDiv=$get(NodeDiv,"/")
532 new result set result=Path
533 if $extract(Path,$length(Path))'=NodeDiv do
534 . set result=Path_NodeDiv
535 ;
536 quit result
Note: See TracBrowser for help on using the repository browser.