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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

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

Post by dmoc »

ChgDir(Path.s)
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

What is that supposed to do?
quidquid Latine dictum sit altum videtur
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Change the current directory?
(Like the Dos-Command ChDir/CD)

But ChgDir() is a bad name. Better ChangeDirectory() or ChDir() (like dos)
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post 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.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post 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.
Horst.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post 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.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post 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 
Horst.
Post Reply