Hi, > This is the changelog entry: > > * contrib/hbide/idemisc.prg > + hbide_PathProc() > This function can combine relative paths together so it's > the key to avoid macros dealing with placing paths to their > intended location. It can replace current method of > <IdeSrc> = hb_dirBase(). F.e.: > hbide_PathProc( "src/mysource_in_project.prg", "projects_dir/" ) > -> > "projects_dir/src/mysource_in_project.prg" > hbide_PathProc( "projects/myproject.hbi", hb_dirBase() ) -> > "C:/harbour/contrib/hbide/projects/myproject.hbi" > Please use it. > > And I was experimenting with it. But I could not got the desired results. > > This is what I tried: > filename_to_be_stored > project_location > hbide_pathProc( "C:\dev_sources\vouch\abc.prg", > "C:\harbour\contrib\hbide\projects\hbide.hbi" ) > and received: > C:\dev_sources\vouch\abc.prg > whereas I was expecting something like: > ../../../../dev_sources/vouch/abc.prg > this way only I can retain the relative paths in .hbi which will be > transferable to > any system and drive. Drive letter or root path is assumed the same. > > Or I am making a mistake ?
Probably you misunderstood the function. This function is useful to create full path for a file, from a _base dir spec_ which is usually an absolute one, and file/dir spec, which is usually a relative one. Notice that it's possible that base dir is a relative dir and it's also possible that file spec is an absolute one, but this should not be a problem for us. If the file/dir spec is an absolute one, it will simply override the base dir. Some examples: BASE-absolute + FILE-relative: 'C:\apps\' + 'data.txt' -> 'C:\apps\data.txt' BASE-relative + FILE-relative: 'myprojects' + 'data.txt' -> 'myprojects\data.txt' BASE-relative + FILE-absolute: 'myprojects' + 'C:\files\myfile' -> 'C:\files\data.txt' BASE-absolute + FILE-absolute: 'C:\apps\' + 'C:\files\myfile' -> 'C:\files\data.txt' The general idea is that an application should never be dependent on where it or its settings/data/other files reside on a machine, and it should find these file even when the app is not started from the executables base directory, or moved away to a different location. This means it should not store absolute paths in its settings, or inside the code (except for known system locations (f.e. autoexec.bat), or when the user specifically selected some files, f.e. history of opened projects). Instead, it should use relative ones in each of these places. And it should rebase all these relative paths to a known base before using it in a file operation. My function does this rebasing. To rebase your must choose a base dir for each situation. Base dir can be based the location of executable (hb_dirbase()), or location of any other known path (f.e. the base file for a multifile 'document', like a parent/root .hbp file). It's important to never store these rebased paths on disk. So for example to open a database which is stored in <app>/data/test.dbf, you do this in code: opendbf( hbide_pathproc( hb_dirbase(), "data/test.dbf" ) ) it will open: <app>/data/testdbf To open a .prg which belongs to a project stored under a project directory you do this: openfile( hbide_pathproc( cProjectFileName, "mysource.prg" ) ) it will open: <projectdir>/mysource.prg Notice that it doesn't matter whether cProjectFileName is an absolute or relative dir, it will work in all cases. You can find many examples for above in hbmk2 source code. I hope that clarifies somehow. Brgds, Viktor _______________________________________________ Harbour mailing list (attachment size limit: 40KB) [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
