VAN0 Posted March 26, 2023 Share Posted March 26, 2023 Hello. Is there a way append files to the compiled script that could be read upon later in the script, without copying it to a hard drive? For example we can append icons via #AutoIt3Wrapper_Res_Icon_Add and then use them as tray icons as TraySetIcon(@ScriptFullPath, 200) Is there a way have similar functionality for text/binary files? Here is a situation: I'm using FileInstall() to copy a file to a specific directory. It's a template that later will be modified if needed. I don't want to overwrite existing file. However in case user modified the file I need a way to overwrite it with the template file when needed. So FileInstall() would only work here if it copied file into temp directory and then copy that file into final destination directory. I'd like to avoid keeping copy of a file somewhere on hardrive or in memory for that matter. Link to comment Share on other sites More sharing options...
AutoBert Posted March 26, 2023 Share Posted March 26, 2023 Look for VAN0 1 Link to comment Share on other sites More sharing options...
TheXman Posted March 26, 2023 Share Posted March 26, 2023 (edited) If you are currently using FileInstall() to initially deploy the file, then why don't you just conditionally do another FileInstall() to overwrite the file if/when you determine that the file has been modified? You are aware that FileInstall() adds a copy of the file to your compiled script already, right? If your issue is how can you determine if the file has been modified, then one quick way is to create and store a cryptographic hash for the template file in your script and compare that hash to a hash generated from the deployed file. If they aren't the same, then the file has been modified. If <condition> Then FileInstall(...) Edited March 26, 2023 by TheXman Corrected a typo VAN0 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Developers Jos Posted March 26, 2023 Developers Share Posted March 26, 2023 (edited) 2 hours ago, VAN0 said: Is there a way have similar functionality for text/binary files? HelpFile or search broken? #AutoIt3Wrapper_Res_File_Add= ; Filename[,Section [,ResName[,LanguageCode]]] to be added. .. but as stated: FileInstall() does more or less the same thing the easy way. Edited March 26, 2023 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
VAN0 Posted March 26, 2023 Author Share Posted March 26, 2023 1 hour ago, TheXman said: If you are currently using FileInstall() to initially deploy the file, then why don't you just conditionally do another FileInstall() to overwrite the file if/when you determine that the file has been modified? I'll be damned. All this time for some reason I thought it doesn't matter where in the script FileInstall() is located, it extracts file when script is executed ones and that's it... @Jos negative side of caching...knew what the function does, why bother look manual again...🤦♂️ So, FileInstall() is what I was looking for, but is there a way get some information about the file before it's being extracted, like size, modified date, etc? Link to comment Share on other sites More sharing options...
TheXman Posted March 26, 2023 Share Posted March 26, 2023 (edited) 2 hours ago, VAN0 said: is there a way get some information about the file before it's being extracted, like size, modified date, etc? Why? You already know all there is to know about the file at the time you compile the script. If you have to have that info, then you can store it in some constants before compiling. If it's because you want to know if the deployed file has been modified, then I already provided a quick & easy way to determine that in my previous reply and it doesn't require reading the template file or any of its properties again. For the record, a file's size and "last modified date" are not accurate ways to determine if a file's contents have been changed. One or more characters within a file can be swapped or replaced and it won't change the file size. Doing something as simple as re-saving a file without making any modifications, will update the "last modified date". So as you can see, you can't rely on those properties to know if a file's contents have changed. However, hashing will let you know if even a single bit has been changed. Edited March 26, 2023 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Skysnake Posted April 5, 2023 Share Posted April 5, 2023 On 3/26/2023 at 6:11 PM, TheXman said: "last modified date". Can also be overwritten by ZIP extraction. I agree, it is almost useless. Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now