Initial import of Scalos. To decrease size I have
[AROS-Contrib.git] / scalos / main / Tools / Scalos_GetHidden / getpath.e
blob6190419a45fd7b2c6e49c776e3220ab3d0c8e597
1 OPT MODULE
2 OPT EXPORT
3 OPT PREPROCESS
5 #define version $VER: GetPath.m 1.0 (02.03.04) BY JMC - Desc: Get parent of file or drawer.
7 EXPORT PROC getpath(currentdir:PTR TO LONG)
8 DEF moins=0,str,pos,test
10 test:=String(StrLen(currentdir))
11 StrCopy(test,currentdir,ALL)
12 IF test[StrLen(test)-1]<>":"
13 IF test[StrLen(test)-1]="/" THEN SetStr(currentdir,StrLen(currentdir)-1)
14 str:=String(StrLen(currentdir))
15 pos:=String(StrLen(currentdir))
16 moins:=0
17 REPEAT
18 MidStr(str,currentdir,0,StrLen(currentdir)-moins)
19 moins:=moins+1
20 UNTIL StrCmp(RightStr(pos,str,1),'/',StrLen(str))=TRUE OR StrCmp(RightStr(pos,str,1),':',StrLen(str))=TRUE
21 StrCopy(currentdir,str,ALL)
22 ELSE
23 StringF(currentdir,'')
24 ENDIF
25 ENDPROC currentdir