Jump to content

Append files to compiled script?


VAN0
 Share

Recommended Posts

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

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 by TheXman
Corrected a typo
Link to comment
Share on other sites

  • Developers
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 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

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

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.  :think:

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 by TheXman
Link to comment
Share on other sites

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...