Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Relative path with camel case
Message
From
14/02/2017 06:28:32
 
 
To
14/02/2017 05:23:38
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01647931
Message ID:
01647942
Views:
79
Likes (1)
>>I'm sure this has been asked, but...
>>
>>Is there a way to obtain a relative path to a file when providing the full path to the file, and a path to another path location. Plus have it returned in proper camel case as it would appear in the system. The SYS(2014) provides the relative path but it is uppercase.
>
>
>relativePath = Sys(2014, "C:\VHdev\appli\Dooxi\Progs\dooxi.scx", Home(1))
>? relativePath && ..\..\VHDEV\APPLI\DOOXI\PROGS\DOOXI.SCX
>
>relativePath = Strtran(;
>  m.relativepath;
>, Strtran(m.relativepath, '..\');
>, Substr("C:\VHdev\appli\Dooxi\Progs\dooxi.scx", Atc(Strtran(m.relativepath, '..\'), "C:\VHdev\appli\Dooxi\Progs\dooxi.scx"));
>)
>? relativePath && ..\..\VHdev\appli\Dooxi\Progs\dooxi.scx
>
WOW. I should of seen this. I guess as I get older, my programming sword is losing it edge.

Anyway, for future reference to all...
* Description: 	return the fullpath to a file is the case found on the disk
* Parameters:  	tcFilename :	name of the file to search for
*				tcRelPath : name/path for form relative path from
* Return:		path to file
* Syntax:		RealFullPath( <file> [,<relpath>] )
*------------------------------------------------------------
*PROCEDURE RelaFullPath
LPARAMETERS tcFilename, tcRelPath

LOCAL ofs, lcFile
lcFile = FULLPATH(tcFilename)
IF FILE(m.lcFile)
	LOCAL ofs, _folder, _file
	ofs = CREATEOBJECT("scripting.FileSystemObject")
	_folder = m.ofs.getfolder(ADDBS(JUSTPATH(m.lcFile)))
	_file = _folder.FILES(JUSTFNAME(m.lcFile))
	lcFile = _file.PATH
ENDIF
*-- resolve relative path
IF PCOUNT()>1
	LOCAL relPath
	relPath = SYS(2014, m.lcFile, FULLPATH(m.tcRelPath) )
	lcFile = STRTRAN( m.relPath, STRTRAN(m.relPath, '..\') , SUBSTR(m.lcFile, ATC(STRTRAN(m.relPath, '..\'), m.lcFile)) )
ENDIF
RETURN lcFile

* EOF REALFULLPATH.PRG
*
Thanks again.
Greg Reichert
Previous
Reply
Map
View

Click here to load this message in the networking platform