Bug 207659 - add temp file creation API to FileObject
add temp file creation API to FileObject
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Filesystems
7.2
PC All
: P3 (vote)
: 7.2
Assigned To: Alexander Simon
issues@platform
cndreq
: API_REVIEW_FAST
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-24 07:37 UTC by Andrew Krasny
Modified: 2012-02-22 11:00 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
initial variant (without implementation) (2.14 KB, patch)
2012-01-31 17:04 UTC, Alexander Simon
Details | Diff
second variant with implementation (8.79 KB, patch)
2012-02-07 15:40 UTC, Alexander Simon
Details | Diff
variant #3 (fixed Y01&Y02) (14.19 KB, patch)
2012-02-13 12:09 UTC, Alexander Simon
Details | Diff
variant #4 (fixed JG01&JG02) (16.31 KB, patch)
2012-02-17 07:26 UTC, Alexander Simon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Krasny 2012-01-24 07:37:23 UTC
Now, when there is an official API for extending FS on remote case, it would be beneficial to add several methods to FileObject to allow users of the API to abstract from disk FS, knowledge about remote host, etc.. 

As an example, some analogue of java.io.File.createTempFile(String prefix, String suffix) and createTempFile(String prefix, String suffix, File directory) and, maybe, deleteOnExit() wanted.

How about adding these methods so that each implementer of FileSystem could provide this functionality?
Comment 1 Jaroslav Tulach 2012-01-24 10:20:39 UTC
java.io.File.createTempFile is static. However, possibly org.openide.filesystems.FileSystem could have method of this kind. 

Donate a patch, otherwise I have no time to work on this.
Comment 2 Alexander Simon 2012-01-31 17:04:52 UTC
Created attachment 115416 [details]
initial variant (without implementation)
Comment 3 Alexander Simon 2012-02-07 15:40:12 UTC
Created attachment 115508 [details]
second variant with implementation
Comment 4 Jaroslav Tulach 2012-02-09 10:05:29 UTC
Y01 Missing versioning, @since tag, apichanges note.
Y02 Add some tests to TCK for those filesystems that support the call.
Comment 5 Alexander Simon 2012-02-13 12:09:52 UTC
Created attachment 115651 [details]
variant #3 (fixed Y01&Y02)
Comment 6 Jesse Glick 2012-02-13 22:26:47 UTC
[JG01] File.createTempFile("tmp", null).getParentFile() can probably be replaced with new File(System.getProperty("java.io.tmpdir")).


[JG02] Maybe need some deleteOnExit parameter for createTempFile?
Comment 7 Alexander Simon 2012-02-14 09:46:40 UTC
(In reply to comment #6)
> [JG01] File.createTempFile("tmp", null).getParentFile() can probably be
> replaced with new File(System.getProperty("java.io.tmpdir")).
Yes, it can be replaced.
My intention was:
- do not use knowledge about how File implements method createTempFile() and delegate all operations to File.
If you insist I can replace this code. But I would prefer to keep my code.

> [JG02] Maybe need some deleteOnExit parameter for createTempFile?
I was thinking about deleteOnExit.
But RFS cannot safely implement this flag.
As a solution I can add flag as "placeholder".
Master FS will implement it.
Remote FS can try to implement it without any guarantee.
Problems:
- connection can be lost
- connection can be closed by user
- IDE closing time is increased
Comment 8 Jesse Glick 2012-02-14 14:03:59 UTC
JG01 - the current code will create a stray file in /tmp which is undesirable. Anyway System.getProperties documents the existence of java.io.tmpdir and its meaning.


JG02 - understood it cannot be fully reliable on a RFS, but if you want people to use FileSystem.cTF instead of File.cTF then there needs to be some replacement for dOE. (Except for cases where the file is only used within some lexical block and can be deleted with a finally clause.)
Comment 9 Alexander Simon 2012-02-17 07:26:54 UTC
Created attachment 115851 [details]
variant #4 (fixed JG01&JG02)
Comment 10 Vladimir Voskresensky 2012-02-17 07:57:25 UTC
looks nice. 

btw, probably unused import in:
masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java
+import java.security.SecureRandom;
Comment 11 Alexander Simon 2012-02-19 07:05:49 UTC
(In reply to comment #10)
> looks nice. 
> 
> btw, probably unused import in:
> masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java
> +import java.security.SecureRandom;
Thanks, will fix
Comment 12 Alexander Simon 2012-02-20 09:35:54 UTC
fixed, change set:
http://hg.netbeans.org/cnd-main/rev/4eb7101f29b6
Comment 13 Quality Engineering 2012-02-21 10:55:21 UTC
Integrated into 'main-golden', will be available in build *201202210400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4eb7101f29b6
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #207659 add temp file creation API to FileObject
Comment 14 Quality Engineering 2012-02-22 11:00:37 UTC
Integrated into 'main-golden', will be available in build *201202220400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4eb7101f29b6
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #207659 add temp file creation API to FileObject


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo