Home Download Buy Blog Forum Support

How to get project path?

How to get project path?

Postby greg on Wed Sep 19, 2012 12:07 am

It seems to have be asked several times, but I couldn't find any answer to this question: how can I get the path of the current project? (from a plugin)

TIA
greg
 
Posts: 34
Joined: Fri Sep 14, 2012 10:00 am

Re: How to get project path?

Postby sapphirehamster on Fri Sep 21, 2012 7:49 pm

window.folders() gives you a list of folders that are in the project. Perhaps that will give you what you want.
sapphirehamster
 
Posts: 74
Joined: Sun Jul 01, 2012 11:19 pm

Re: How to get project path?

Postby greg on Sat Sep 22, 2012 10:25 am

Thanks for your answer.

I found window.folders(), but it's not what I want. This is an arbitrary list of folders, I'm looking for the project file itself.
greg
 
Posts: 34
Joined: Fri Sep 14, 2012 10:00 am

Re: How to get project path?

Postby phillip.koebbe on Sun Sep 23, 2012 12:29 am

Take a look at facelessuser's FavoriteFiles plugin. There is some functionality that needs to know where the project file is, but I believe when he did it, it was pretty much a kludge. I haven't looked at the code in a long time, so he may have found a more elegant way to do it.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: How to get project path?

Postby facelessuser on Sun Sep 23, 2012 12:57 am

No, it is still a kludge, but yes I have do have a way to get the project path. In general, it is pretty straight forward, but the file you have to parse isn't always up to date...meaning you can't get the project path unless you force this particular file to update. That is were it gets ugly.
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

Re: How to get project path?

Postby greg on Mon Sep 24, 2012 11:55 am

No, it is still a kludge, but yes I have do have a way to get the project path. In general, it is pretty straight forward, but the file you have to parse isn't always up to date...meaning you can't get the project path unless you force this particular file to update. That is were it gets ugly.

I see... do you think it's better to have the user explicitly set the path in some config file?
greg
 
Posts: 34
Joined: Fri Sep 14, 2012 10:00 am

Re: How to get project path?

Postby facelessuser on Mon Sep 24, 2012 2:44 pm

greg wrote:I see... do you think it's better to have the user explicitly set the path in some config file?


Depends on what you want to do. It is certainly the easiest thing to do. Hopefully one day Jon will expose this in the API. I am sure it is always up to date in some memory buffer, but that only gets flushed out to the file on very specific events.
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

Re: How to get project path?

Postby greg on Wed Sep 26, 2012 6:05 am

I've done a plugin to sync the source folder of my web projects with the web root folder.

So I'll use pathes explicit set in config files until the API is exposed.

Thanks for your help!
greg
 
Posts: 34
Joined: Fri Sep 14, 2012 10:00 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 3 guests