Hi Alistair,
________________________________ From: Alistair Grant [via Smalltalk] <[email protected]> Sent: Monday, July 3, 2017 7:29 PM To: Rajula Vineet Reddy(IMT2014045) Subject: Re: The new implementation of current working directory Hi Rajula, On Thu, Jun 29, 2017 at 05:42:02AM -0700, Rajula Vineet wrote: > Hi all, > > As I have already been posting about my GSoC work and updates on my blog > <https://vineetreddy.wordpress.com> and on the mailing list > <http://forum.world.st/template/NamlServlet.jtp?macro=search_page&node=1294792&query=gsoc+Rajula+&days=0> > . In this post, I would like to go in depth of my work on 'the working > directory' so that I can get valuable feedback and suggestions from > everyone. This discussion was started on an github PR > <https://github.com/pharo-project/pharo/pull/96> which was conflicting my > PR. It looks like my concerns were unfounded, but many thanks for taking the trouble to follow up on this. Not a problem. Indeed thanks for making me do it. I got to learn something new and improved my knowledge on this issue. It would good if you could keep a similar caching strategy to the one I introduced as the performance gains can be significant (as suggested by Cyril's comment). Yeah. Sure. I have used the same caching strategy and made changes to my pull request. Thanks again, Alistair Thank you, Rajula > Firstly, I would like to go through the current implementation of the > working directory. With this implementation, when you use the > defaultWorkingDirectory method, the directory in which the running image is > present in, is returned. This is not a completely good working because when > you run the image from a different directory like './pharo ../Pharo.image' > the working directory is the one in which your image resides. But that isn`t > your actual working directory. Due to this, > > 1. Pharo cannot be installed as a normal application in a read-only > environment. > 2. Pharo wrongly reads and writes files relative to the 'working directory'. > 3. It also makes scripting difficult. > > In the FogBugz issue here > <https://pharo.fogbugz.com/f/cases/5723/Default-Working-Directory> , there > is an example which explains the problem. > > Let say the Pharo VM and Image are in the directory "~/Pharo", > and I wrote a script in "~/Documents/Pharo-scripts" called > "perfect-numbers.st" > > I have 2 possibilities: > > cd ~/Pharo && pharo Pharo.image st > ~/Documents/Pharo-scripts/perfect-numbers.st // works > > or > > cd ~/Documents/Pharo-scripts && pharo ~/Pharo/Pharo.image st > perfect-numbers.st // doesn't work... > > It doesn't work because when pharo wants to load the file, > it tries to locate it with: FileSystem disk workingDirectory !!! > which is NOT the current working directory." > > I hope you get the problem. > > So for the new implementation <https://github.com/rajula96reddy/pharo-cli> [https://avatars1.githubusercontent.com/u/9512824?v=3&s=400]<https://github.com/rajula96reddy/pharo-cli> rajula96reddy/pharo-cli<https://github.com/rajula96reddy/pharo-cli> github.com pharo-cli - Enhancements to pharo command line interface > with the help of Guille I researched about $PWD and getcwd() for a while and > wrote a new implementation. This is how it goes > 1. I have written new methods in OSPlatorm 'getPwdFromFFI' and > 'getPwdFromFFIwithsize:'. These call the getcwd() function using the UFFI > 2. And a new method currentWorkingDirectoryPath and > currentWorkingDirectoryPathWithBufferSize: in OSPlatform which uses the > above method and gets the working directory. > 3. To integrate this, I have patched the DiskStore method > 'defaultWorkingDirectory' to use the new methods in OSPlatform. > > I have checked all the sendors of the 'defaultWorkingDirectory' for any > issue. And I also wrote some unit tests. So, the new implementation is > working fine. With this, now I am able to get the right working directory. > The example mentioned above works perfectly. > > But, there may be a few cases where it can break interoperability between > Pharo and other Smalltalk dialects like squeak etc. And the 'pharo-local' > directory and its methods should also be patched subsequently. In fact, > these problems can be tackled by running image from its own directory itself > (which is obvious ;) ) or by using the method imageDirectory in FileLocator > class explicitly when necessary. But overall a good thing is this is will > ensure the system will behave as in other languages. > > I have completed this implementation and submitted a PR > <https://github.com/pharo-project/pharo/pull/92> to github. But because of [https://avatars1.githubusercontent.com/u/9512824?v=3&s=400]<https://github.com/pharo-project/pharo/pull/92> 05723-Default-Working-Directory by rajula96reddy · Pull Request #92 · pharo-project/pharo<https://github.com/pharo-project/pharo/pull/92> github.com This is a new pull request, the last one had unnecessary commits. > some dependency issue, it has not yet been merged. With the help of my > mentor, I am working on the problem. > > Thanks for reading all this. Please give your feedback and comments on this > new implementation. Your suggestions help me in learning more about the > project and also about the organization. > > Thanks, > Rajula > > > > -- > View this message in context: > http://forum.world.st/The-new-implementation-of-current-working-directory-tp4952918.html Pharo Smalltalk Developers - The new implementation of current working directory<http://forum.world.st/The-new-implementation-of-current-working-directory-tp4952918.html> forum.world.st The new implementation of current working directory. Hi all, As I have already been posting about my GSoC work and updates on my blog and on the mailing list . In this post, I would like to go in... > Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com. > ________________________________ If you reply to this email, your message will be added to the discussion below: http://forum.world.st/The-new-implementation-of-current-working-directory-tp4952918p4953299.html Pharo Smalltalk Developers - The new implementation of current working directory<http://forum.world.st/The-new-implementation-of-current-working-directory-tp4952918p4953299.html> forum.world.st The new implementation of current working directory. Hi all, As I have already been posting about my GSoC work and updates on my blog and on the mailing list . In this post, I would like to go in... To unsubscribe from The new implementation of current working directory, click here<http://forum.world.st/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4952918&code=VmluZWV0LlJlZGR5QGlpaXRiLm9yZ3w0OTUyOTE4fC02NDg3MDY=>. NAML<http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> -- View this message in context: http://forum.world.st/The-new-implementation-of-current-working-directory-tp4952918p4954071.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
