Bug 119244 - API to get a java.io.File from a URI
Summary: API to get a java.io.File from a URI
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.2 M5   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-05 09:49 EST by Jerome Lanneluc CLA
Modified: 2006-01-11 12:18 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2005-12-05 09:49:05 EST
I20051130

To transparently support zip files on any file system, JDT Core would need an API that converts a URI to a java.io.File. This would be the same as IPath#toFile() if the resource is on the local file system, otherwise this would copy the resource on the local file system (in the metadata area ?), and return a java.io.File on this copy.
Comment 1 John Arthorne CLA 2005-12-08 15:10:58 EST
Target for M5.
Comment 2 John Arthorne CLA 2005-12-20 18:15:58 EST
I have released an initial API and implementation to HEAD.  See IFileStore.toLocalFile.  It has two main usage modes.

1) A file that store that already is a local file:

store.toLocalFile(EFS.NONE, pm) -> returns null if the store is not a local file

2) A file in any store:

store.toLocalFile(EFS.CACHE, pm) -> Creates a cached local copy of the file, regardless of what file system it is in.

Not yet extensively tested...
Comment 3 John Arthorne CLA 2006-01-05 13:50:44 EST
I have fleshed out the implementation and added more test suites.  This API is ready to be tried out.
Comment 4 Jerome Lanneluc CLA 2006-01-11 10:46:00 EST
Thanks for the new API, John. I have some questions/comments though:

1. According to you comment, EFS.CACHE will create a copy of the file even if it is local. However the spec suggest otherwise ("a cached representation of a file should be created if necessary").

2. Is the copy updated if the file changes on the remote file system ?

3. This might not be necessary, but the spec could say where the copy is placed (I guess in the .metadata) and what the name of the java.io.File.
Comment 5 John Arthorne CLA 2006-01-11 12:18:39 EST
1. Thanks, I have fixed this comment. In my first prototype I would return either the local file or the cached file if CACHE was specified, but I think the client needs to know if they are dealing with a cached copy or the real file.

2. No, the copy is not updated.  There is currently no mechanism for the file system to report changes, so this would require polling.  The intent is that the the client calls toLocalFile every time they need it, and the implementation can optimize the case where the cached copy is the same as the backing file system.

3. I wanted to avoid this because I don't want to recreate the entire directory structure for the cached file.  If there are multiple cached files with the same name I need to be generating different file names to avoid collision.