(view source code of truename.rex as plain text)
/* TRUENAME.CMD */
/* Equivalent for MS-DOS' TRUENAME command (at least for */
/* NET USEd drives) */
/* Written by Rob van der Woude */
/* http://www.robvanderwoude.com */
/* */
/* Written for both OS/2 2.1+ and Windows 95/NT with Regina */
/* Rexx (Resource Kit) and Patrick TJ McPhee's RegUtil */
/* (http://www.interlog.com/~ptjm/) */
/* Initialize RexxUtil if necessary */
if RxFuncQuery( "SysDriveMap" ) <> 0 then do
call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
call SysLoadFuncs
end
parse upper arg parameters
if parameters = "" then call Syntax
if pos( "?", parameters ) > 0 then call Syntax
if pos( "/", parameters ) > 0 then call Syntax
if pos( ",", parameters ) > 0 then call Syntax
if pos( ";", parameters ) > 0 then call Syntax
select
when left( parameters, 2 ) = "\\" then call Syntax
when left( parameters, 1 ) = "\" then do
drive = left( directory( ), 2 )
path = parameters
end
when length( parameters ) < 2 then do
drive = left( directory( ), 2 )
path = substr( directory( )||parameters, 3 )
end
when substr( parameters, 2, 1 ) = ":",
& datatype( left( parameters, 1 ), "U" ) = 1 then do
drive = left( parameters, 2 )
path = substr( parameters, 3 )
end
otherwise do
drive = left( directory( ), 2 )
path = substr( directory( )||parameters, 3 )
end
end
parse upper source os .
localdrives = SysDriveMap( "A", "LOCAL" )
if pos( drive, localdrives ) > 0 then do
truename = drive||path
say truename
EXIT 0
end
start = "A"
do i = 65 to 90
char = D2C( i )
if pos( char||":", localdrives ) = 0 then leave
start = D2C( i + 1 )
end
/*
do i = 1 by 1 until localdrives = ""
parse value localdrives with local.i localdrives
local.0 = i
end
*/
remotedrives = SysDriveMap( start, "REMOTE" )
if pos( drive, remotedrives ) > 0 then do
tempfile = SysTempFileName( "TRUE????" )
'@NET USE '||drive||' | find "\\" > '||tempfile
line = linein( tempfile )
call lineout tempfile
parse value line with ."\\"strunc
unc = "\\"||strunc
if left( path, 1 ) <> "\" then do
"@CD "||drive||" > "||tempfile
line = linein( tempfile )
call lineout tempfile
path = substr( line, 3 )
end
call SysFileDelete tempfile
truename = unc||path
say truename
EXIT 0
end
say "UNKNOWN"
EXIT 1
Syntax: procedure
call SysCls
say
say "TrueName, Version 1.01"
say "Partial port of MS-DOS' TRUENAME command"
say "Written by Rob van der Woude"
say "http://www.robvanderwoude.com"
say
say "Usage: TRUENAME { drive | path | filename }"
say
say "Returns: the local name or UNC of the specified drive/path/filename"
EXIT 1
return
page last modified: 2024-04-16; loaded in 0.0070 seconds