Identifying file updations in NSIS - nsis

In NSIS is there any way to identify whether the application file is modified from the user side while updating the application using installer?
My requirement is while updating the application, we need to give warning message in case of user modify the application file. If 'Yes' we need to update the file, otherwise we should not update.

You probably have two options; you can get the modified time with GetFileTime or use something like the MD5 plugin (md5dll::GetMD5File).
You could save the original values in a .ini when you install and then compare with these values when updating...

Use archive attribute. Archive attribute is there especially for such purpose.
Below steps demonstrates the behaviour of archive bit:
Unset archive bit of any file in your pc, using Properties > advanced > untick "File is ready for archiving"
Edit and save the file with an appropriate tool. For example Notepad for a text file.
Note that archive bit of the file is set, signalling that this file is modified.
So the method will be like this:
Unset archive bit of all necessary source files in NSIS compiler PC
In NSIS script use [File /a] to extract the source files to destination computer preserving attributes
While reinstalling use GetFileAttributes to detect if the file is modified or original and take steps accordingly.

Related

How to make a list of file extensions read only in JetBrains IDEs?

I have a code generation tool (build_runner) that generates source code based on existing source files.
Every generated file is meant to be read-only.
How to tell JetBrains IDE to prevent me (as a developer) to edit those files? (or at least warn me a confirmation dialog before I actually edit the file)
Those files are identified with specific extensions
*.generated.dart
*.unwrapped.dart
Make your tool set file permissions on the files it generates: chmod 444.
Make your tool put the files in the generated folder like other libraries do.
Sample from Android Studio after setting the file permission on this file and trying to edit it:

How to set default file extension of saving file for specific syntax in Sublime Text 3

The C++ standard doesn't rule the file extension, so the most of people use .cpp, but I prefer using .cc, how to tell Sublime Text save to .cc when using C++ syntax as default?
The way to change the default file extension shown by the save-as dialog when saving a file set to a specific syntax is to override that syntax's default .sublime-syntax file. In your case that would be the C++.sublime-syntax file.
Of course, as MattDMo points out, the easiest thing to do is to manually type the preferred file extension whenever you save a file. But for those that want to make the change, here's how to do it.
Open the Command Palette and select View Package File.
Type C++ and then select C++/C++.sublime-syntax. ST will open the file.
Near the top you should see file_extensions: and a list like this:
file_extensions:
- cpp
- cc
- cp
- cxx
- c++
...snip...
ST uses the 1st item in the file_extensions list as the default file extension for the save-as dialog.
To make .cc the default extension instead of .cpp, edit the list order so that - cc is the 1st item and - cpp is 2nd, i.e. swap the top 2 lines around.
Now save the file in your ST config Packages directory with this path: ../Packages/C++/C++.sublime-syntax. If you like you can create a C++ directory in Packages and then just use Ctrl+S to save because the path will have been automatically set by ST but the file won't save unless the ../Packages/C++/ directory already exists.
Note: The full path on a Linux machine would be like this: /home/user/.config/sublime-text-3/Packages/C++/C++.sublime-syntax
The Package Resource Viewer plugin's Open Resource Command Palette command could be used to extract .sublime-syntax files instead of ST's native View Package File command. That plugin will automatically create the appropriate Packages directory when necessary.
Your altered Packages/C++/C++.sublime-syntax file will now override the default version that is shipped with ST. You can reverse this easily simply by deleting the file. It is safe to delete the directory as well if you are not overriding any other files in the same directory.
The only problem with this is when you install a new version of ST. If the newly installed version has an updated C++.sublime-syntax file, the local one you've created will continue to override the new one. To get around this delete your altered Packages/C++/C++.sublime-syntax file when you install a new version of ST and repeat the steps above to restore your preferred default file extension once the installation has been done.
Unfortunately there is no way around this, you can not partially override the C++.sublime-syntax file with just the file_extensions: section. Of course new versions of ST don't come along very frequently and the C++.sublime-syntax file gets updated even less often. So this is not a major issue.

How may I create a package installer and extract the contents only in a specific folder

Edit: Oops my bad! I wasn't clear enough... I guess I need to explain more...
I need to create a package installer for my customers. I want them to extract and overwrite the contents only in their specific folder.
I don't want them to be able to extract the contents wherever they want to let them steal my work /or know what my files are all about.
So I was thinking maybe the installer could be created in a way to check for a file name inside the folder and after the file name has been recognized then it can be simply extracted and overwritten and if not then the operation will be cancelled.
Any Idea ?
Assuming you're running Windows...If the file name is recognised in the specified extraction folder, then it'll prompt you to either overwrite or cancel. - Either using Window's own extractor or something like 7Zip will achieve this.
Okay, so I believe this might help:
https://superuser.com/questions/259353/7-zip-windows-7-make-extract-to-folder-default-on-double-click
Particularly Haiggoh's comment:
1.Start regedit as administrator
2.Open HKEY_CLASSES_ROOT\7-Zip.7z
3.Under that key, expand the Shell sub-key
4.Set the (Default) value to the string extract
5.Create a new sub-key named extract
6.Set the (Default) value for the extract key to Extract to Folder
7.Create a new sub-key under extract named command
8.Set the (Default) value of the command key to:
C:\ProgramFiles\7-Zip\7zG.exe x "%1" -o* (you might have to a adjust
this to match the path of you 7zip installation)
Instead of 7z with -aou like Justin Roettger suggested I ended up
using 7zG, because this way you can choose to overwrite if you like
just like extracting with the normal context menu.
That's it! 7z files are now extracted to a folder with their own name
by double click. For other extensions like .rar and .zip you need to
repeat these steps for the according keys. (i.e.
HKEY_CLASSES_ROOT\7-Zip.rar and HKEY_CLASSES_ROOT\7-Zip.zip and so on)
Oh and to clarify: It does work with multiple files selected as well.
No batch file need.
Have a read through the above and hopefully it'll point you in the right direction.

Where are the default packages in Sublime Text 3 on Ubuntu?

I'm migrating from Sublime Text 2 to 3. In Sublime Text 2, I changed a lot of the default settings of the editor -- such as the tab bar height, sidebar color, etc. -- by modifying the Default.sublime-theme file in sublime-text-2/Packages/Theme - Default. I was also able to modify the colors of the default color schemes in a similar fashion. I've been trying to figure out how to do this for Sublime Text 3, but can't seem to find these files. ~/.config/sublime-text-3 only seems to contain overrides for user settings, not the default settings.
This link on the Sublime Text forums seems to give the location for Windows and Mac, but not for Ubuntu. I've searched a bit to no avail. Does anyone have suggestions?
Thank you!
To amplify on #skuroda's answer - ST3 contains all of its data that, in ST2, was stored in Packages/PackageName, in PackageName.sublime-package files that are basically just zip files, or "Resources" as they're now known. Using PackageResourceViewer, you can easily edit the individual files contained within the resource, then save it back again. When saved, the proper directory structure under Packages/PackageName will be created, allowing you to edit the file directly next time. The way file precedence works in Sublime, any file that exists in ~/.config/sublime-text-3/Packages/PackageName/ will override any file of the same name stored in PackageName.sublime-package.
However, since you don't want these files to be accidentally overwritten, I would suggest creating ~/config/sublime-text-3/Packages/User/Themes/ and User/Color Schemes directories and storing your customized files there instead. The User/ directory is protected from overwrites during upgrades, etc., and unless you're planning on creating a customized theme or color scheme for redistribution through Package Control, it's best practice to keep your files in there.
EDIT
I just realized you hadn't gotten an answer to your original question - where are the files stored? If you installed the .deb file from sublimetext.com, all the .sublime-package files are in /opt/sublime_text/Packages.
If you want the easiest way to save your customized settings first copy all the default settings and paste into a new file named Preferences.sublime-settings.
Then make your changes and save the file to:
/home/**username**/.config/sublime-text-3/Packages/User
In order to see the .config folder you will have to enable show hidden files.
The instructions are written at the top of the default settings list in case you are wondering where got this from.
In the ST console, try entering sublime.executable_path(). This should get you close to where you need to be. Also, you should copy the content of the file out and move them (under a new name to the packages folder). You probably don't want your modifications to be reverted on subsequent update. An alternative method is to try overriding the files you need to. I haven't done that for theme files, so I'm unsure if everything will work as it should. If you take the override route, I'd recommend using PackageResourceViewer. I wrote it to help with browsing/overriding package files in ST3.
You can use
dpkg -L <package name>
For example
dpkg -L subli<tab>
Just open up sublime text, hit ctrl+` to open sublime text console, then run these command accordingly
sublime.packages_path() to see user installed packages directory
sublime.installed_packages_path() to see zipped packages (with .sublime-package file type) directory
Mostly likely, you'll find the Default package inside zipped packages directory.
You can use PackageResourceViewer to see zipped packages's contents as #MattDMo suggested, but more over, you can actually extract zipped packages into user installed package directory directly using PackageResourceViewer's extract command.

Can a Self Extracting Zip File read a registry entry?

I'm trying to get my website to talk to a friend's program. Think ITunes - one main program with hundreds of thousands of little things installed into it. We don't want to have to create an InstallShield install program for each of those hundreds of thousands of little things.
We have the files grouped into the folder sub-structure.
We have a .REG file for what registry entry needs to be added to see the new folder group.
But is there a way to do a self extracting zip file that reads a registry entry so we know where they installed the original program to be able to dump the new files there as well? I want them to double-click the EXE and click Finish and for everything to work.
(I've been looking into INF and CAB files through IExpress.exe, but haven't found the answer. I remember Package for the Web didn't have an option to read a registry entry, but did let you modify the suggested install path.)
Thanks so much.
Best wishes,
Andrea
But is there a way to do a self extracting zip file that reads a registry entry so we know where they installed the original program to be able to dump the new files there as well? I want them to double-click the EXE and click Finish and for everything to work
Well, yes and no. There are self-extractors that can run a program after extracting all files. DotNetZip, for example, can produce an SFX which can do this.
Just an aside: a normal SFX is just a zip file, with a "stub" executable merged with it. The stub exe can do anything it wants to do, but the most basic thing it does is extract the files in the zip. When you use DotNetZip to produce an SFX, it embeds its particular stub into the zip. That stub knows how to extract files, and also knows how to invoke a program after extracting. You can also produce your own stub that can do other more exotic things.
So you could use an SFX for your purpose. When run, it would extract, then invoke it's extra program. The program could look in the registry, then move or relocate the extracted files to the appropriate place. Then terminate.
For a different twist, the SFX might have just two files: the program-to-run (the one that reads the registry, and another embedded zip. Then when the SFX runs it generates 2 files. Then it invokes the program-to-run, which reads the registry, then unpacks the contained zip and puts the files into the desired place.
Ok, so you could do it.
Should you?
mmm, maybe. This really is an installer, so, you should decide whether you want to use a zip as an installer. Don't forget, if you use an SFX as an installer, there's no good way to uninstall.
Have you tried Inno Setup toolchain? It's a bit better than a bare Self-Extracting ZIP file, it's a setup creation utility. I'm convinced it has got something to put some entry in the Registry, look also at the plugins.
Basically, a self-extracting executable that alters the registry, it's a setup program. So why don't you go for a proper one?
Website: http://www.jrsoftware.org/isinfo.php

Resources