Can someone describe me of Atlas(sprite sheet) making process that is the process of making ".des" files from ".png" files ?
Related
I have codes to watch a folder and open to read new files. When new file(s) fall into folder program works and do what it should do. Problem is related with other next file(s). If another file(s) fall into folder, program is giving "File is being used by another process" error message. I already read every similar questions in Stackoverflow and in Google. But non of them solved my problem. I don't think that problem is with my codes since when I assign same codes to a button and click manually after file falls to folder, program is working properly. But when FileSystemWatcher runs those codes it gives error at second time. Is there anyone who can advise a solution ?
I couldn't find the reason of the problem but I found my own solution.
I gave-up using FileSystemWatcher, instead I created a timer for 1 minute and at the end I check file quantity in the folder. If there is any change, I run the main codes. Now my problem has been fixed.
For example:
Program A is writing log to file "test.log".
If logrotate runs, it will rename "test.log" to "test.log.1" first, and then create a new file "test.log".
After step 2, program A does not report any error, but the A's log does not appear in the new file "test.log".
The questions are:
Where is the data that A write to file after step 2 ?
How can logrotate rename and create new file when another process is writing to the file? (Is any point that I miss about logrotate?)
Thanks!
This is very tightly related to how POSIX filesystems work. When you rename a file, it's only the name of the file that is changed, the physical file on the disk will not change. Also, once a file is opened, the process using the file only have a link (through many layers) to the physical file on the disk, the name is only used when opening the file.
That means the program A will still write to the same file, which now has the new name (i.e. test.log.1 in your example).
A common solution to this problem is to have the log rotation program send a signal (e.g. SIGHUP or SIGUSR1 or similar) to the process. The process will detect this signal and then reopen the logging to use the new file.
Situation
I just ran into an odd situation that should not happen often, but I would like to prevent it from ever happening again.
I have a chunk of code that creates a deep dive directory list of all the files in a source folder and all of its children folders.
In general this has never been a problem, until today.
I had a fellow dev that accidentally set a symlink of a sub folder to point back at the parent folder. This caused my deep dive to recuse until it crashed.
For example:
topfolder
topfolder/sub1 - real folder
topfolder/sub2 - symlink back to topfolder
My code read all the files in topfolder and then all files in topfolder/sub1 with no problems. Then, since topfolder/sub2 points back to topfolder I read all the files in topfolder/sub2, which are the same as in topfolder and then topfolder/sub2/sub1 and then topfolder/sub2/sub2 and on to topfolder/sub2/sub2/sub2, etc.
My question
Is there a way, in node.js to determine the destination of a symlink? I figure if I can create a list of folders I have read and, when running into the symlink above, I determine that the destination is really a folder I have already read then I just skip that folder.
Thanks in advance...
Is there a way, in node.js to determine the destination of a symlink?
Yes. fs.readlink(dir) will return the destination of the symlink if it is one, an error otherwise.
fs.readlink("sub2", function(err, destination){
if(err)
//sub2 is not a symlink, proceed to go into it
else if(destination)
//sub2 is a symlink, check if 'destination' is a folder we have already been through
});
I have an applescript that I would like to improve performance. Someone mentioned using node.js. I'm new to this and was wondering if the following is possible in node. I have a series of folders (say, Folder A, Folder B, etc.) and in these folders are subfolders named Main and Thumbnails. What my applescript does is pull all the files out of the Main folder into the root folder (Folder A, Folder B), then deletes the Main folder and the Thumbnails folder (files in Thumbnails are not needed).
Is this something that can be done in node.js?
Is this something that can be done in node.js?
Yes. But it is also something that can be done even simpler with a shell script.
But technically the answer to your question is: Yes.
Some APIs that you will most likely need to use:
https://nodejs.org/api/fs.html
https://nodejs.org/api/path.html
Some modules that can help you simplify concurrency:
https://www.npmjs.com/package/mz
https://www.npmjs.com/package/async
https://www.npmjs.com/package/bluebird
I am working on VC++ project, in that my application process a file from input path and generates 3 output "*.DAT" files in the destination path. I will FTP these DAT file to the destination server. After FTP, I need to delete only two output .DAT files the folder. I am able to delete those files, because there one Asynchronous thread running behind the process. Since the thread is running, while deleting it says, "Cannot delete, the file is used by another person".
I need to stop that thread and delete the files. Multiple files can also be taken from the input path to process.
Please help me in resolving this issue. Its very high priority issue for me. Please help me ASAP.
I don't think this is a threading issue. Instead I think your problem is that Windows won't let you delete a file that still has open handles referencing it. Make sure that you call CloseHandle on handles to the file that you want to delete first. Also ensure that whatever mechanism you are using to perform the FTP transfer doesn't have any handles open to the file you want to delete.
I don't think that forcing the background thread down will solve your problem. You can't delete the files because you're holding an open handle to those files. You must close the handle first. Create an event object and share it between your main thread and the background thread. When the background thread is done sending the files through FTP, it should set this event. Have your main thread wait on the event before deleting the files.
Background Thread:
SendFiles();
ReleaseResources(); // (might be necessary, depending on your design)
SetEvent( hFilesSentEvent );
Main Thread:
WaitForSingleObject( hFilesSentEvent );
DeleteFiles();