Removing certain files on startup - startup

How do you, on startup, remove certain files from the computer. I guess you use stdlib but I can't find any functions for deleting files.
So. How do you delete files when the computer boots up ?

Related

Is it safe to delete SymStore's deleted transaction files?

We are using a SymStore on a fileshare and I recently noticed, that there are over 100k transaction files in the 000admin folder. About 95 % of these files have an .deleted extension, because they have been already deleted.
So is it safe to delete those files to save some space and make life easier for NTFS?
TLDR: no, in general it is not safe to delete these files.
Long answer: SymStore can do different operations, main of which are "add" and "delete". On every operation it changes files in 000Admin folder, adding there information about what was added or what was deleted. Later this information can be used by other SymStore commands, like "symstore query" command, for example. If you delete some of the transaction files from 000Admin folder - it means history of commands will not be accurate anymore and "symstore query" can't work properly.
Of course, if you are 100% sure you don't use such commands and you just need to store pdb files - you can delete files in 000Admin. However, you should understand some functionality of SymStore will not be available to you anymore.

Should we not avoid manually purging iOS tmp and Caches folders?

Use this directory to write temporary files that do not need to persist between launches of your app. Your app should remove files from this directory when they are no longer needed; however, the system may purge this directory when your app is not running.
https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
There are conflicting answers about the need to manually clear the tmp folder. There is no API for clearing it, it must be performed manually file by file (which says something). More importantly, we should always avoid unnecessarily overworking the disk because it will wear out the SSD (Apple's Data Storage Guidelines mentions this also), and purging a folder file by file that's designed to be purged by the OS routinely seems counterintuitive.
Would it not be best practice then to delete what we know for certain isn't needed anymore as it comes our way (on-the-spot cleaning) and let the rest be purged by the OS and avoid manual purging altogether?
And should we not apply this strategy to the Library/Caches folder as well, since that folder's cleaning policy is the same as the tmp folder's?
You said:
Would it not be best practice then to delete what we know for certain isn't needed anymore as it comes our way (on-the-spot cleaning) and let the rest be purged by the OS and avoid manual purging altogether?
Yes, the documentation is telling you that when you create a temporary file, that you should just remove it as soon as you’re done with it. There’s no “manual purging” or sweeping of this folder needed. Just delete the individual files when you’re done with them.
And should we not apply this strategy to the Library/Caches folder as well, since that folder's cleaning policy is the same as the tmp folder’s?
If you know for certainty that you don’t need a particular cached file anymore, then absolutely delete it.
But often with caches, you don’t know when a particular file isn’t needed anymore, so we often resort to LRU-style logic based up the quantity, size, or cost of the assets.
But in both cases, you want to clean up as appropriate, to prevent unbridled growth in storage. You want to avoid using persistent storage for assets that are no longer needed

Remote Debugging in Delphi XE8 and Delphi 10 Seattle - How can I use a fixed remote directory?

To debug remotely with Delphi, now that the PAServer is normally used, one usually follows the following preliminary steps, as outlined on the online docwiki:
Create a remote profile inside your ide, in my case I'm calling it win7vm, this contains the IP address of the remote system, and a few options, and the PAServer connection password, but as far as I can see, it doesn't contain any context information like "I want to use the following remote folders".
The remote folders that are usually used to contain my target executable are usually a subdirectory underneath the scratch directory. If I configure the main scratch directory to be c:\scratch, and my remote profile was named win7vm and my project is name project1, then the IDE and PA Server are going to compile and deliver my executable to c:\scratch\win7vm\project1 and run it from there.
What I actually want is to have my executable be delivered to and run right in #c:\scratch#. I have a gigabyte of supporting files that all need to be in the same directory as my main executable and I don't want to have 8 copies of these supporting files. So, can this be done? Can I make PA Server NOT create a sub-folder with the name of my project and another for the name of my session? If so, is this done inside the paserver.config file, or on my client side, or somewhere else?
Update: I tried to change the Remote Path in the Project -> Deployment, but it does not work to use a relative path here. For example, change it to ..\..\ and the working directory in Project Options to ..\..\, but it still only delivers my executable to the folder c:\scratch\win7vm\project1 instead of directly into c:\scratch\
Update 2: It appears you can't do what I want, which is have the scratch directory be the main folder, and NOT create any sub-folders per-profile and per-project, and that if you don't like working in a scratch sub-folder, you should just set Absolute Remote Paths in Deployment and Absolute working folder in your project's Run options, and you should turn off restricted mode, however this means that the entire VM or machine you are remotely debugging can be manipulated by the PAServer, which is also hardly ideal. I believe that having a fixed root scratch folder would be a safer and more flexible way of working, so I'm leaving this question open, hoping to find an effective way to achieve a safe but flexible remote debugging technique.

How to find out which computer made the changes to a shared folder with delphi?

I am writing a program with Delphi that monitors a shared folder on my computer, where other people on the network have read-write access to it, I can log changes and info of changed files, but how can I find out which computer made the changes?
Is it possible to find the computer name or IP?
note: using ReadDirectoryChangesW.
If you poll files opened remotely on your pc and match them with monitored directory you might catch which computer opened the file. In order to not miss any short remote access to your files, hooking might be a better idea. An example utility that can show remotely opened files is psfile from pstools.

Selecting a folder created in automator, with another action in automator

I am relatively new to using Automator and I have been tasked with coming up with a way to duplicate files into multiple folders, as well as adding those images into subfolders.
I need to make a folder of images duplicate into two other separate folders, while deleting the originals after duplication. I have that part figured out and up and running without any problems.
But the next part has me stumped. I need to create a subfolder with the name 'Backup' with today's time on it, which I have done as well. Unfortunately, I need to move the duplicated files into it and I can't for the life of me figure out how to do it.
So the process is as follows:
Files dumped into 'Originals' folder
Files duplicated into 'Backup' and 'Retouch' folders
Deleting of files from 'Originals'
Creation of new subfolders in Backup and Retouch with a time stamp added to it
Moving of files from Backup and Retouch, into Backup and Retouch subfolders (with timestamps)
It has taken me this long to create all this, and I'd like to do it all automated without anyone having to select any files at all after starting the folder action. If there is any help that you might give me in this endeavor, I'd appreciate it.

Resources