[Gambas-user] Path specification

Gianluigi bagonergi at gmail.com
Sun Aug 19 14:30:47 CEST 2018


2018-08-19 13:58 GMT+02:00 Tobias Boege <taboege at gmail.com>:

> On Sun, 19 Aug 2018, Gianluigi wrote:
> > 2018-08-19 11:47 GMT+02:00 Tobias Boege <taboege at gmail.com>:
> >
> > > On Sat, 18 Aug 2018, Hans Lehmann wrote:
> > > > Hello Charlie,
> > > >
> > > > what is special about the following line with regard to the path
> > > > specification:
> > > >
> > > > Dim sFile As String = File.Load("../.project")
> > > >
> > > > ?
> > > >
> > >
> > > This is documented here: http://gambaswiki.org/wiki/cat/path
> > >
> > > A relative path starting with ".." references a data file in the
> > > currently running *project*, even if that code is executed from
> > > a component or library.
> > >
> > > Regards,
> > > Tobi
> > >
> > > --
> > > "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> > >
> >
> > Hi Tobias,
> > I find this explanation of the wiki unclear.
> > From it, after compilation, it would seem that the concept of the
> "current
> > project" no longer exists.
>
> It very much exists. The "current project" is where relative paths are
> resolved to. What you don't have is a "current working directory".
>
> > But this simple code should work even after compilation, right?
> >
> > Note: The file "foo.txt" is located inside the project data folder.
> >
> > Public Sub Main()
> >
> >   Dim sPath As String = "/tmp/path-test"
> >
> >   Try Mkdir sPath
> >   If Error Then Return
> >   Try Copy "./foo.txt" To sPath &/ "foo.txt"
> >
> > End
> >
>
> Yes, this copies the file "foo.txt" in your project directory to the
> temporary location. The difference between "." and ".." (BTW, "./foo.txt"
> is the same as "foo.txt", even in this context) is that if you write a
> component or library and load "foo.txt" in code running inside the
> component, you access resources of the component project, not of the
> project that is currently running and using that component.
>
> If you want access from the component code to resources in the currently
> running project, then you use "../foo.txt". gb.web.form does this,
> for example, to serve files in your project's .public folder (think
> favicon,
> css and javascript resources) without you having to think about it.
>
> All of that works no matter if you are executing the project from the IDE,
> from the project directory or a compiled .gambas archive.
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
>
Hi Tobias,
thank you very much.
Finally I understood what the wiki's explanation means :-)

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180819/f729dcfd/attachment.html>


More information about the User mailing list