How to change current working directory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to change current working directory

Terry Arnold
I know about File >>workingDirectory but how does one *change* the current
working directory from within a Dolphin app? I need to run (#_spawnvp)
programs from within specified directories, so I need to "go there" first
and then call #_spawnvp:


Reply | Threaded
Open this post in threaded view
|

Re: How to change current working directory

Udo Schneider
Terry,

based on you needs Bob Jarvis' ExternalProccess package (available here:
http://www.nls.net/mp/jarvis/Bob/DolphinGoodies.htm) might help you.

I'm not sure why you are using #_spanvp: but the package above offers
the possibility to set the working directory and start the process (either
blocking and non-blocking).

CU,

Udo


"Terry Arnold" <[hidden email]> schrieb im Newsbeitrag
news:40d0c021$[hidden email]...
> I know about File >>workingDirectory but how does one *change* the current
> working directory from within a Dolphin app? I need to run (#_spawnvp)
> programs from within specified directories, so I need to "go there" first
> and then call #_spawnvp:
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How to change current working directory

Louis Sumberg-2
In reply to this post by Terry Arnold
Terry,

> I know about File >>workingDirectory but how does one *change* the current
> working directory from within a Dolphin app?

These might work.  I implemented them some time ago but haven't used them.
e.g.,
    SessionManager current currentDirectory: 'c:\pathname'.

SessionManager>>currentDirectory: aString
"Set the current directory for the current process. Answer whether or
not successful."
^KernelLibrary default setCurrentDirectory: aString

KernelLibrary>>setCurrentDirectory: aString
"Set the current directory for the current process.
BOOL SetCurrentDirectory(
LPCTSTR lpPathName <>
);"
<stdcall: bool SetCurrentDirectoryA lpstr>
^self invalidCall

Likewise, a set of methods to return the current directory - I suppose this
is redundant vis a vis File>>workingDirectory (but the symmetry is there).

SessionManager>>currentDirectory
"Answer a String pathname that is the current directory for the current
process.  Signal an exception if the request fails."
| buffer ret |
buffer := File pathBuffer.
(ret := KernelLibrary default getCurrentDirectory: buffer size buffer:
buffer) = 0 ifTrue: [KernelLibrary default systemError].
^buffer leftString: ret asInteger

KernelLibrary>>getCurrentDirectory: nBufferLength buffer: lpBuffer
"Answer the current directory for the current process.
DWORD GetCurrentDirectory(
DWORD nBufferLength <>,
LPTSTR lpBuffer <>
);"
<stdcall: dword GetCurrentDirectoryA dword lpstr>
^self invalidCall

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: How to change current working directory

Dominique Dartois-2
In reply to this post by Terry Arnold
I implemented the setter method for the working directory like that :

CRTLibrary>>_chdir: dir
   "Set the current working directory to dir."
   <cdecl: sdword _chdir lpstr>
   ^self invalidCall

File>>workingDirectory: dir
   "Set the current working directory."
   ^(CRTLibrary default _chdir: dir) = 0


In article <40d0c021$[hidden email]>, Terry Arnold wrote:

> From: "Terry Arnold" <[hidden email]>
> Newsgroups: comp.lang.smalltalk.dolphin
> Subject: How to change current working directory
> Date: Wed, 16 Jun 2004 14:39:17 -0700
>  
> I know about File >>workingDirectory but how does one *change* the current
> working directory from within a Dolphin app? I need to run (#_spawnvp)
> programs from within specified directories, so I need to "go there" first
> and then call #_spawnvp:
>

----
Dominique Dartois