Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: CIAUOS1

CIAUOS1.m

Go to the documentation of this file.
  1. CIAUOS ;MSC/IND/DKM - Platform-dependent operations;04-May-2006 08:19;DKM
  1. ;;1.2;CIA UTILITIES;;Mar 20, 2007
  1. ;;Copyright 2000-2006, Medsphere Systems Corporation
  1. ;=================================================================
  1. ; Return version # of RTL
  1. VER() ;EP
  1. Q +$P($T(CIAUOS+1),";",3)
  1. ; Set right margin
  1. RM(X) ;EP
  1. X ^%ZOSF("RM")
  1. Q
  1. ; Test for routine/tag
  1. TEST(X) ;EP
  1. N Z
  1. S:X[U Z=$P(X,U),X=$P(X,U,2)
  1. Q:'$L(X)!(X'?.1"%"1.AN) 0
  1. X ^%ZOSF("TEST")
  1. Q $S('$T:0,$G(Z)="":1,Z'?.1"%"1.AN:0,1:$T(@Z^@X)'="")
  1. ; Raise an exception
  1. RAISE(X) ;EP
  1. ZT $G(X)
  1. ; Return code to set error trap
  1. TRAP(X) ;EP
  1. Q $$SUBST^CIAU(^%ZOSF("TRAP"),"X",""""_X_"""")
  1. ; Check for $ET capability
  1. ETRAP() ;EP
  1. Q $$NEWERR^%ZTER
  1. ; Open a file (extrinsic)
  1. OPENX(X1,X2) ;EP
  1. D OPEN(.X1,.X2)
  1. Q X1
  1. ; Open a file
  1. OPEN(X1,X2) ;EP
  1. N IO,POP,X3
  1. D PARSE(.X1,.X3),OPEN^%ZISH(X3_X1,X3,X1,$G(X2,"R"),32767)
  1. I POP ZT "OPEN"
  1. S ^XTMP("CIAUHFS",$J,IO)=X3_X1,X1=IO
  1. Q
  1. ; Close a file
  1. CLOSE(X) ;EP
  1. N Y
  1. S Y=$G(^XTMP("CIAUHFS",$J,X)),IO=X
  1. K ^(X)
  1. D CLOSE^%ZISH(Y)
  1. Q
  1. ; Close all open HFS
  1. CLOSEALL ;EP
  1. N Z
  1. S Z=""
  1. F S Z=$O(^XTMP("CIAUHFS",$J,Z)) Q:Z="" D CLOSE(Z)
  1. Q
  1. ; Parse out directory from filename
  1. PARSE(X,Y) ;EP
  1. N D,Z
  1. S D=$E($$DIRDLM,3),Z=$L(X,D),Y=$P(X,D,1,Z-1),Y=$S($L(Y):Y,1:$$PWD^%ZISH)_$S(Z>1:D,1:""),X=$P(X,D,Z)
  1. Q
  1. ; Read a line
  1. READ(X,Y) ;EP
  1. N IO,%ZA,%ZB,%ZC,%ZL
  1. S IO=$G(Y,$I)
  1. D READNXT^%ZISH(.X)
  1. U IO
  1. Q $$STATUS^%ZISH&'$L(X)
  1. ; Delete a file
  1. DELETE(X) ;EP
  1. N Z
  1. D PARSE(.X,.Z)
  1. S:$L(X) Z(X)="",Z=$$DEL^%ZISH(Z,"Z")
  1. Q
  1. ; Rename a file
  1. RENAME(X1,X2) ;EP
  1. N X3,X4
  1. D PARSE(.X1,.X3),PARSE(.X2,.X4)
  1. I $$MV^%ZISH(X3,X1,X4,X2)
  1. Q
  1. ; List files
  1. DIR(X1,X2,X3) ;EP
  1. N Z
  1. D PARSE(.X1,.Z)
  1. S Z(X1)="",X3=$G(X3,"^UTILITY(""DIR"",$J)")
  1. K @X3
  1. I $$LIST^%ZISH(Z,"Z",X3)
  1. Q
  1. ; Force error if at EOF
  1. EOF I $$STATUS^%ZISH ZT "EOF"
  1. Q
  1. ; Returns true if current error is EOF
  1. EOFERR() ;EP
  1. Q $$EC^%ZOSV["EOF"
  1. ; URL format filename-->HFS format
  1. CVTFN(CIAFIL,CIAROOT) ;EP
  1. N CIAZ,CIAZ1,CIAD
  1. S CIAD=$$DIRDLM,CIAROOT=$G(CIAROOT)
  1. S:$E(CIAROOT,$L(CIAROOT))=$E(CIAD,3) CIAROOT=$E(CIAROOT,1,$L(CIAROOT)-1)
  1. S CIAZ=$L(CIAFIL,"/"),CIAZ1=$P(CIAFIL,"/",1,CIAZ-1),CIAFIL=$P(CIAFIL,"/",CIAZ)
  1. S:$L(CIAZ1) CIAROOT=CIAROOT_$E(CIAD,$S($L(CIAROOT):2,1:1))_$TR(CIAZ1,"/.-",$E(CIAD,2))
  1. Q CIAROOT_$S($L(CIAROOT):$E(CIAD,3),1:"")_CIAFIL
  1. ; Return directory delimiters
  1. DIRDLM() ;EP
  1. N X
  1. S X=$$PWD^%ZISH
  1. Q $S(X["[":"[.]",X["\":"\\\",1:"///")
  1. ; Parse error data
  1. ERR(X1,X2,X3) ;EP
  1. N X
  1. S X=$$EC^%ZOSV,X1=$$VERSION^%ZOSV(1)
  1. G ERRMSM:X1["MSM",ERRDSM:X1["DSM"
  1. S (X1,X2,X3)=""
  1. Q
  1. ERRMSM S X1=$E($P(X,">"),2,99),X2=$P($P(X,">",2),":"),X3=X1
  1. S:X2["*" X2=""
  1. S:$E(X1)="Z" X3=$E(X1,2,99),X1="ZTRAP"
  1. Q
  1. ERRDSM S X1=$P($P(X,", ",2),"-",3),X2=$P($P(X,", "),":"),X3=$$TRIM^CIAU($P(X,", ",$S(X1="ZTRAP":4,1:3)))
  1. Q