Anu
Anu

Reputation: 405

How to check one file is saved or not?

How can I check one file(IFile) is saved or not?There is one method in IOpenable interface for checking saved or not.But in this case how can I get IOpenable from IFile?

Upvotes: 2

Views: 433

Answers (3)

Volker Stolz
Volker Stolz

Reputation: 7402

Assuming everyone is well-behaved, you can try using FileBuffers.getTextFileBufferManager().getFileBuffer(...) and then check the obtained buffer(s) with IFileBuffer.isDirty().

Upvotes: 2

nicephotog
nicephotog

Reputation: 41

just loosely, you could create a file object to use to save something like this but that is dependent exactly how you derive the java.io.File object itself in the Eclipse framework. so just figuratively coded...

class MySaveFile extends java.io.File implements org.eclipse.jdt.core.IOpenable,org.eclipse.core.resources.IFile{

MySaveFile(String savefilename){
super(savefilename);
}//end constructor


} //end class

URL: here's an actual example for eclipse http://www.eclipsezone.com/eclipse/forums/t65832.html

Upvotes: 0

Anshu
Anshu

Reputation: 7853

IResource that is the parent of IFile and IFolder and has the method exist() which you can use to check whether the resource exist or not.

Upvotes: 0

Related Questions