On Sat, Dec 16, 2017 at 12:01 PM, Ben Coman <b...@openinworld.com> wrote: > > > On 16 December 2017 at 16:02, Stephane Ducasse <stepharo.s...@gmail.com> > wrote: >> >> Hi ben >> >> We should think about it. Indeed. >> Now about the names. I'm wondering if they cover well enough the >> situation. >> In fact I would like to have imageDirectory (it exists but not in >> FileSystem) and workingDirectory (I would prefer startupDirectory or >> something like that). > > > startupDirectory sounds like its where the startup scripts are kept, > and common across many Images. > >> For me workingDirectory is totally unclear. > > > Its a fairly well defined concept. Its starts as the shell directory where > you > type the command to run a program. > https://en.wikipedia.org/wiki/Working_directory
then we keep it. > We should align with the operating system since file access is ultimately > through system calls like fopen() where relative paths are ultimately > affected by > what the operating > system considers to be the working directory (or do we *always* fully > resolve paths > in-Image and only pass absolute paths to fopen() ?) > > Here is a demonstration of working directory on Unix ... > > > $ mkdir temp && cd temp > > $ cat << 'EOF' > testcwd.c > #include <unistd.h> > #include <stdio.h> > char buf[1000]; > int main() > { printf("MYCWD=%s\n", getcwd(buf,1000)); > } > EOF > > $ gcc testcwd.c -o testcwd > > $ ./testcwd > MYCWD=/home/ben/dev/temp > > $ cd .. > > $ temp/testcwd > MYCWD=/home/ben/dev > > > i.e. its the directory where the command was typed in to run the program. > > Since we build on Windows using Cygwin/Ming, its basically the same semantic > for Windows. > and even Win32 has similar function GetCurrentDirectory().... > https://msdn.microsoft.com/en-us/library/windows/desktop/aa364934(v=vs.85).aspx > > > Now I guess confusion may arise when in Pharo you want to "change the > working directory". > if we only modify some in-Image instance variable? Then a difference of > opinion might arise > between Pharo and operating system calls as to what is the > working-directory" when > relative paths are used. > > Perhaps we should only refer to the operating system's current working > directory. > (Sorry I'm not in a position to dig into that right now) > > > cheers -ben > >> >> >> Now this change is super important for making Pharo >> a good platform for script execution. So let me make it even nicer. >> >> Stef >> >> >> On Fri, Dec 15, 2017 at 10:14 PM, Ben Coman <b...@openinworld.com> wrote: >> > >> > >> > On 16 December 2017 at 04:34, Cyril Ferlicot D. >> > <cyril.ferli...@gmail.com> >> > wrote: >> >> >> >> Le 15/12/2017 à 21:24, Hilaire a écrit : >> >> > In P3: >> >> > >> >> > FileSystem disk workingDirectory >> >> > =>File @ >> >> > /home/hilaire/Travaux/Developpement/DrGeoII/Dev-pharo3.0/shared >> >> > >> >> > In P7: >> >> > >> >> > FileSystem disk workingDirectory >> >> > =>File @ /home/hilaire >> >> > >> >> > Is it a bug? >> >> > >> >> >> >> Hi! >> >> >> >> In Pharo 3 >> >> >> >> workingDirectory = imageDirectory. >> >> >> >> In Pharo 7 >> >> >> >> workingDirectory = directory from where Pharo was launched. >> > >> > >> > just double-checking... >> > with equivalent shell commands... >> > $ DIR1 = `pwd` >> > $ $DIR2/pharo $DIR3/Pharo.image >> > >> > Pharo 3 ==> workingDirectory = $DIR3 >> > Pharo 7 ==> workingDirectory = $DIR1 >> > ? >> > >> > I wonder for such a semantic API change it might be good to >> > introduce #workDirectory and deprecate #workingDirectory >> > so the need for user-devs to change their code is more explicit. >> > It might make easier to have an auto-conversion rule #workingDirectory >> > ==> >> > #imageDirectory, >> > and make it harder to shoot yourself in the foot producing >> > cross-platform >> > libraries. >> > >> > cheers -ben >> > >> > >> >> >> >> >> >> Maybe you launched Pharo from the terminal with this command like this >> >> one? >> >> >> >> Travaux/Developpement/DrGeoII/Dev-pharo3.0/shared/pharo-ui >> >> Travaux/Developpement/DrGeoII/Dev-pharo3.0/shared Pharo.image >> >> >> >> If you wish to use the old behaviour, you can replace `FileSystem disk >> >> workingDirectory` by `FileLocator imageDirectory asFileReference`. >> >> >> >> This change was done because, not getting the real working directory >> >> make it really hard to script things in Pharo. >> >> >> >> -- >> >> Cyril Ferlicot >> >> https://ferlicot.fr >> >> >> >> http://www.synectique.eu >> >> 2 rue Jacques Prévert 01, >> >> 59650 Villeneuve d'ascq France >> >> >> > >> >