Relative filename

View: New views
4 Messages — Rating Filter:   Alert me  

Relative filename

by Ishan Chattopadhyaya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I want the path of the currently open file relative to the project.
Project path: /path/to/Project
Current file path: /path/to/Project/src/test.py
I want: src/test.py

I looked at:
gchar* ianjuta_document_get_filename (IAnjutaDocument *obj, GError
**err);
for the current document from docmanager, but I get only the filename,
not the path.

Please help,
Regards,
Ishan



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Anjuta-devel mailing list
Anjuta-devel@...
https://lists.sourceforge.net/lists/listinfo/anjuta-devel

Re: Relative filename

by James Liggett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ishan,

On Sun, 2009-08-16 at 00:16 +0530, Ishan Chattopadhyaya wrote:
> Hi,
> I want the path of the currently open file relative to the project.
> Project path: /path/to/Project
> Current file path: /path/to/Project/src/test.py
> I want: src/test.py
The best way to do this is to keep a copy of the project root path in
your plugin and do something like:

g_strdup (full_path + strlen (project_root_dir) + 1);

Where full_path is the full path of the file for which you want a
relative path and project_root_dir is the root directory of the
currently open project. The + 1 is to make sure that the slash between
the project root directory and the start of the relative path is also
skipped over, so you get "relative/path" instead of "/relative/path".

HTH,
James


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Anjuta-devel mailing list
Anjuta-devel@...
https://lists.sourceforge.net/lists/listinfo/anjuta-devel

Re: Relative filename

by Ishan Chattopadhyaya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

How do I even get the full path of the open file in the editor?

On Sat, 2009-08-15 at 13:55 -0700, James Liggett wrote:

> Hi Ishan,
>
> On Sun, 2009-08-16 at 00:16 +0530, Ishan Chattopadhyaya wrote:
> > Hi,
> > I want the path of the currently open file relative to the project.
> > Project path: /path/to/Project
> > Current file path: /path/to/Project/src/test.py
> > I want: src/test.py
> The best way to do this is to keep a copy of the project root path in
> your plugin and do something like:
>
> g_strdup (full_path + strlen (project_root_dir) + 1);
>
> Where full_path is the full path of the file for which you want a
> relative path and project_root_dir is the root directory of the
> currently open project. The + 1 is to make sure that the slash between
> the project root directory and the start of the relative path is also
> skipped over, so you get "relative/path" instead of "/relative/path".
>
> HTH,
> James
>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Anjuta-devel mailing list
Anjuta-devel@...
https://lists.sourceforge.net/lists/listinfo/anjuta-devel

Re: Relative filename

by Ishan Chattopadhyaya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks James :-)

----- irc.gnome.org (#anjuta) -----
(05:11:55 AM) jrliggett: ishan: you'll need to add a watch for the
current editor filename
(05:12:57 AM) jrliggett: take a look at the git plugin to see how this
is done (plugin.c)
(05:15:56 AM) jrliggett: to summarize, what you'll do here is call
anjuta_plugin_add_watch with an
IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT in your activate_plugin
method. This function takes a callback which you will then use to make a
copy of the current editor filename and keep in in your plugin structure
(07:03:41 AM) ishan: jrliggett: thanks! I'll try it :)
(08:05:34 AM) ishan: jrliggett: wonderful, thanks!


On Sat, 2009-08-15 at 13:55 -0700, James Liggett wrote:

> Hi Ishan,
>
> On Sun, 2009-08-16 at 00:16 +0530, Ishan Chattopadhyaya wrote:
> > Hi,
> > I want the path of the currently open file relative to the project.
> > Project path: /path/to/Project
> > Current file path: /path/to/Project/src/test.py
> > I want: src/test.py
> The best way to do this is to keep a copy of the project root path in
> your plugin and do something like:
>
> g_strdup (full_path + strlen (project_root_dir) + 1);
>
> Where full_path is the full path of the file for which you want a
> relative path and project_root_dir is the root directory of the
> currently open project. The + 1 is to make sure that the slash between
> the project root directory and the start of the relative path is also
> skipped over, so you get "relative/path" instead of "/relative/path".
>
> HTH,
> James
>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Anjuta-devel mailing list
Anjuta-devel@...
https://lists.sourceforge.net/lists/listinfo/anjuta-devel