Getting VirtualFile object.

Hi,

I have location of a file that does not exist on the file system. Can I get its VirtualFile object? I used VcsUtil, but it is returning NULL.

Thanks
Devang Shah

8 comments
Comment actions Permalink

Hi Alex,

Even that does not seem to work. While specifiying the URL, I will have to prepend the path with 'file:///', right? I tried without 'file:///' and with 'file:///', however it did not work.

Thanks
Devang Shah

0
Comment actions Permalink

Devang Shah wrote:

I have location of a file that does not exist on the file system. Can I get its VirtualFile object? I used VcsUtil, but it is returning NULL.


As far as I know, you cannot get VF objects for non-existing files. What do you need it for?

Sascha

0
Comment actions Permalink

Hi,

I am implementing a VCS plugin. Plugin provides a search wherein deleted files are shown (those not present on file system, but alive in the repository). When I perform right click in the searhes view, I obtain the absolute path of the file. Using this path, I want the VirtualFile object to decide the which actions should be enabled or disabled.

Hope this makes clear.

Thanks
Devang Shah

0
Comment actions Permalink

AFAIK, the previous poster is right, VirtualFile are null for non existing files.

You should be able to create a FilePath for it though, would that be enough for you ?

0
Comment actions Permalink

Hi,

I was able to get the FilePath object. However I need VirtualFile object. Is there no way to do this?

Thanks
Devang Shah

0
Comment actions Permalink

Devang Shah wrote:

I am implementing a VCS plugin. Plugin provides a search wherein deleted files are shown (those not present on file system, but alive in the repository). When I perform right click in the searhes view, I obtain the absolute path of the file. Using this path, I want the VirtualFile object to decide the which actions should be enabled or disabled.

Hope this makes clear.


Hmm, I'm not familiar with the VCS APIs, but I still don't understand what exactly you need the
VirtualFile for. If you need it because of some other API dependency, you should be able to create
you own VirtualFile implementation that represents the file in your VCS.

Sascha

0
Comment actions Permalink

Hello Devang,

I was able to get the FilePath object. However I need VirtualFile
object. Is there no way to do this?


Well, you can try to provide your own VirtualFileSystem implementation and
return VirtualFiles from that filesystem for files which don't exist in the
real filesystem. However, the correct (and much simpler) solution for your
problem is indeed, as has already been recommended, to use FilePath objects
instead of VirtualFile.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.