This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | add temp file creation API to FileObject | ||
---|---|---|---|
Product: | platform | Reporter: | Andrew Krasny <akrasny> |
Component: | Filesystems | Assignee: | Alexander Simon <alexvsimon> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | apireviews, issues, jglick |
Priority: | P3 | Keywords: | API_REVIEW_FAST |
Version: | 7.2 | ||
Hardware: | PC | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Attachments: |
initial variant (without implementation)
second variant with implementation variant #3 (fixed Y01&Y02) variant #4 (fixed JG01&JG02) |
Description
Andrew Krasny
2012-01-24 07:37:23 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. Created attachment 115416 [details]
initial variant (without implementation)
Created attachment 115508 [details]
second variant with implementation
Y01 Missing versioning, @since tag, apichanges note. Y02 Add some tests to TCK for those filesystems that support the call. Created attachment 115651 [details]
variant #3 (fixed Y01&Y02)
[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? (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 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.) Created attachment 115851 [details]
variant #4 (fixed JG01&JG02)
looks nice. btw, probably unused import in: masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java +import java.security.SecureRandom; (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 fixed, change set: http://hg.netbeans.org/cnd-main/rev/4eb7101f29b6 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 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 |