Page 1 of 1

UseDirectory(Path.s) or even better...

Posted: Sat Nov 08, 2003 2:54 pm
by dmoc
ChgDir(Path.s)

Posted: Sat Nov 08, 2003 8:27 pm
by freak
What is that supposed to do?

Posted: Sat Nov 08, 2003 9:03 pm
by GPI
Change the current directory?
(Like the Dos-Command ChDir/CD)

But ChgDir() is a bad name. Better ChangeDirectory() or ChDir() (like dos)

Posted: Sat Nov 08, 2003 9:06 pm
by dmoc
Freak, can't seem to change the current path, even using SetCurrentDirectory or UseDirectory(). Further calls to ExamineDirectory() still refer to app path (unless of course full/rel path spec supplied)

GPI, agreed, whatever, as long as there is a x-platform method.

Posted: Sat Nov 15, 2003 11:22 am
by horst
There are two different things:

PureBasic's <b>default</b> directory is not (necessarily) the <b>current</b> directory.

If you have a command parameter with a file name based on the
current directory, you have to get the current directory by
API and construct the full path.

What we need is a PB command:
SetPBdefaultDirectory(path)
or:
SetPBdefaultToCurrentDirectory()

Of course it would be better if PB would use the current directory
as default, but that would not be backward compatible.

Posted: Wed Mar 17, 2004 9:02 pm
by dmoc
bump: anyone have a solution? For example, I want to allow the user to select a directory to become the default from which the program can then open files using *relative* paths such as "data/mylogo.bmp" or "../global/stdlogo.bmp". I'd prefer not be constantly fixing-up paths just because PB won't register a directory change.

Posted: Fri Mar 19, 2004 8:04 pm
by horst
dmoc wrote:... I want to allow the user to select a directory to become the default from which the program can then open files using *relative* paths such as "data/mylogo.bmp" or "../global/stdlogo.bmp". I'd prefer not be constantly fixing-up paths just because PB won't register a directory change.
Currently the only solution is using the API funktion:
GetFullPathName_(...)

I made this small PB function for my batch tools:
(This one ignores empty source srings)

Code: Select all

Procedure.s CompletePath(fname.s)
If fname 
  buf_.s = Space(#MAX_PATH) :  fp_.l 
  len = GetFullPathName_(fname,#MAX_PATH,@buf_,@fp_)
  If len : fname = buf_ : EndIf 
EndIf 
ProcedureReturn fname
EndProcedure