Using IFile to get the absolute path of a file in my project [message #154040] |
Thu, 25 May 2006 20:42  |
Eclipse User |
|
|
|
Originally posted by: bswaim.liferay.com
Hi all,
I've been working on this for about 3 hours now, and it's time to ask
for help. I have the following code:
IWorkspace ws = ResourcesPlugin.getWorkspace();
IProject p =
ws.getRoot().getProject("com.liferay.eclipse.myCollPlugin");
IFile f = p.getFile("plugin.xml");
if (f.exists()) {
System.out.print(ws.getRoot());
}
String t = f.getFullPath().toString();
System.out.println(t);
the output of this is /com.liferay.eclipse.myCollPlugin/plugin.xml
I would expect it to be d:/liferay/projects/plugindev/plugin.xml
My goal here is to be able to edit xml files in a specific location in
my project. Do I absolutely have to state the name of the project or
can I just have it grab the currently active project? That's secondary
cuz I can just say your project has to be named x for this to work. My
main issue right now is that I can't figure out how to get access to
the files inside my project without hard coding them to my specific
system which is no good.
Thanks in advance,
Brett
|
|
|
|
Re: Using IFile to get the absolute path of a file in my project [message #154140 is a reply to message #154108] |
Fri, 26 May 2006 12:09   |
Eclipse User |
|
|
|
Originally posted by: bswaim.liferay.com
Okay, I changed it to this:
IPath path =
ResourcesPlugin.getWorkspace().getRoot().getProject("com.liferay.eclipse.myCollPlugin ").getLocation();
but IPath always comes back as null, why do I have to specify the
project name? Can't I just say use the current project?
Brett
On Fri, 26 May 2006 11:50:08 +0100, Matt Dickie <matt@querix.com>
wrote:
>Hi,
>
>You want the location of the file, use:
>file.getLocation()
>
>see:
> http://wiki.eclipse.org/index.php/FAQ_What_is_the_difference _between_a_path_and_a_location%3F
>
>Matt
>
>bswaim@liferay.com wrote:
>> Hi all,
>>
>> I've been working on this for about 3 hours now, and it's time to ask
>> for help. I have the following code:
>>
>> IWorkspace ws = ResourcesPlugin.getWorkspace();
>>
>> IProject p =
>> ws.getRoot().getProject("com.liferay.eclipse.myCollPlugin");
>> IFile f = p.getFile("plugin.xml");
>> if (f.exists()) {
>> System.out.print(ws.getRoot());
>> }
>>
>> String t = f.getFullPath().toString();
>>
>> System.out.println(t);
>>
>> the output of this is /com.liferay.eclipse.myCollPlugin/plugin.xml
>>
>> I would expect it to be d:/liferay/projects/plugindev/plugin.xml
>>
>> My goal here is to be able to edit xml files in a specific location in
>> my project. Do I absolutely have to state the name of the project or
>> can I just have it grab the currently active project? That's secondary
>> cuz I can just say your project has to be named x for this to work. My
>> main issue right now is that I can't figure out how to get access to
>> the files inside my project without hard coding them to my specific
>> system which is no good.
>>
>> Thanks in advance,
>> Brett
|
|
|
Re: Using IFile to get the absolute path of a file in my project [message #154172 is a reply to message #154040] |
Fri, 26 May 2006 12:57  |
Eclipse User |
|
|
|
Originally posted by: bswaim.liferay.com
OMG, I am so dumb.
I was trying to reference a projec that didn't exist, I forget it put
me in a new workspace... I've wasted two days because I never setup a
project in the first place so there was nothing to reference when the
new eclips env loaded... AAAARRRGGHHH!!!
thanks for your help
On Thu, 25 May 2006 17:42:42 -0700, bswaim@liferay.com wrote:
>Hi all,
>
>I've been working on this for about 3 hours now, and it's time to ask
>for help. I have the following code:
>
>IWorkspace ws = ResourcesPlugin.getWorkspace();
>
> IProject p =
>ws.getRoot().getProject("com.liferay.eclipse.myCollPlugin");
> IFile f = p.getFile("plugin.xml");
> if (f.exists()) {
> System.out.print(ws.getRoot());
> }
>
> String t = f.getFullPath().toString();
>
> System.out.println(t);
>
>the output of this is /com.liferay.eclipse.myCollPlugin/plugin.xml
>
>I would expect it to be d:/liferay/projects/plugindev/plugin.xml
>
>My goal here is to be able to edit xml files in a specific location in
>my project. Do I absolutely have to state the name of the project or
>can I just have it grab the currently active project? That's secondary
>cuz I can just say your project has to be named x for this to work. My
>main issue right now is that I can't figure out how to get access to
>the files inside my project without hard coding them to my specific
>system which is no good.
>
>Thanks in advance,
>Brett
|
|
|
Powered by
FUDForum. Page generated in 0.09883 seconds