temporary-files

/tmp vs. /dev/shm for temp file storage on Linux?

☆樱花仙子☆ 提交于 2019-11-30 00:24:23
问题 I have scripts that make hundreds of quick succession, small, temp files needing to be created and very soon read back in, then unlinked. My testing shows little if any performance difference by putting said files in /tmp (to disk) or into /dev/shm (filesystem-level shared memory) on Linux even under moderate load. I attribute this to the filesystem cache. Granted the disk will eventually get hit with the fileystem actions, but on multiple small write-read temp files, why would you (not)

What is a safe way to create a Temp file in Java?

做~自己de王妃 提交于 2019-11-29 22:45:48
I'm looking for a safe way to create a temp file in Java. By safe, I mean the following: Name should be unique, even under potential race conditions (e.g. another Thread calls the same func at the same time, or another process runs this code simultaneously) File should be private, even under potential race conditions (e.g. another user tries to chmod file at high rate) I can tell it to delete the file, without me having to do a generic delete, and risk deleting the wrong file Ideally, should ensure file is deleted, even if exception is thrown before I get the chance to File should default to a

git creates files ending in ~?

情到浓时终转凉″ 提交于 2019-11-29 13:09:46
Just started using git on my mac. I have one file in my repository called README . When I change it, git puts another file in the directory called README~ containing the previous version. Is it git doing this? Why is git doing this? How can I stop git doing this? (don't just want to add it to .gitignore , but I guess I could do that but I'd rather understand why I'm getting these files in the first place..) (It's hard to search for an answer on Google cos of trying to search on "~") The tilde suffix on file names is usually used by editors (Emacs, Vim in some modes/versions) on backup copies

Font.createFont leaves files in temp directory

拜拜、爱过 提交于 2019-11-29 10:02:26
The code below does its work but leaves copies of the font file in the temp directory each time it is run. These files are named +~JF7154903081130224445.tmp where the number seems random for each created file. InputStream fontStream = this.getClass().getResourceAsStream("handsean.ttf"); Font baseFont = Font.createFont(Font.TRUETYPE_FONT, fontStream); fontStream.close(); I have found years-old discussions in forums at sun.com and other resources on the web where this is recognized as a bug in JDK, where upgrading from 1.5.0_06 to 1.5.0_08 would solve the problem; however, the version I am using

Force close file by its path on Windows

浪子不回头ぞ 提交于 2019-11-29 08:04:21
I'm writing a temporary file manager for other developers. I want to remove files even our console applications crashes or being closed by "X" button. So far I found std::set_terminate , std::atexit and SetConsoleCtrlHandler methods with which I can delete all temporary files I need. Problem is - I can't delete opened files. Furthermore - I cant control streams to those files, cause developers using several libraries (GDAL for example) which uses their own stream mechanisms and can accept only a target file path. How can I force close and delete all files, opened by current application? You

is there an existing FileInputStream delete on close?

江枫思渺然 提交于 2019-11-29 01:14:35
Is there an existing way to have a FileInputStream delete the underlying file automatically when closed? I was planning to make my own utility class to extend FileInputStream and do it myself, but I'm kinda surprised that there isn't something already existing. edit: Use case is that I have a Struts 2 action that returns an InputStream for file download from a page. As far as I can tell, I don't get notified when the action is finished, or the FileInputStream is not in use anymore, and I don't want the (potentially large) temporary files that are generated to be downloaded left lying around.

C++: Getting a temporary file, cross-platform

谁说我不能喝 提交于 2019-11-28 22:24:37
I'm looking for a cross-platform way of getting designated a temporary file. For example in linux that would be in the /tmp dir and in Windows in some crappy named Internet Explorer temp dir. Does a cross-platform (Boost?) solution to this exist? EDIT : I need this file to exist until the program terminates. tmpfile() does not guarantee that. Quoting from ccpreference: The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally. The Boost Filesystem library, from version 3 of that library, can be used to create a temporary file

how to use tempfile.NamedTemporaryFile() in python

纵然是瞬间 提交于 2019-11-28 21:28:43
问题 I want to use tempfile.NamedTemporaryFile() to write some contents into it and then open that file. I have written following code: tf = tempfile.NamedTemporaryFile() tfName = tf.name tf.seek(0) tf.write(contents) tf.flush() but I am unable to open this file and see its contents in notepad or similar application. Is there any way to achieve this? Why cant I do something like: os.system('start notepad.exe ' + tfName) at the end 回答1: This could be one of two reasons: Firstly, by default the

When are Java temporary files deleted?

不打扰是莪最后的温柔 提交于 2019-11-28 17:21:34
Suppose I create a temporary file in Java with the method File tmp = File.createTempFile(prefix, suffix); If I do not explicity call the delete() method, when will the file be deleted? As an intuition, it might be when the JVM terminates, or earlier (by the Garbage Collector), or later (by some Operating System sweeping process). The file won't be deleted automatically, from the JavaDoc : This method provides only part of a temporary-file facility. To arrange for a file created by this method to be deleted automatically, use the deleteOnExit() method. So you have to explicitly call

Pipe vs. Temporary File

你说的曾经没有我的故事 提交于 2019-11-28 16:52:24
Is there a big performance difference between: Process A writing to a temp file, and process B reading that file Process A writing to a pipe, and process B reading from that pipe I'm curious to know what the answer is for both Windows and *nix. EDIT: I should have asked: Does the buffer cache eliminate the difference between a temp file and a pipe? One big difference is that with the pipe, processes A and B can be running concurrently, so that B gets to work on the output from A before A has finished producing it. Further, the size of the pipe is limited, so A won't be able to produce vastly