hide directory in rails project - ruby

I have create a new directory with
FileUtils.mkdir_p 'backupFiles' unless File.exists?('backupFiles')
how ever i like this folder to be hidden from CL and within the text editor visualisation of the rails project.
Any hints or advise how to do so?
and if the folder is hidden would it still be accessible by my program ? (e.g. with FileUtils.cp_r "./app", "backupFiles/")

This will be hard to answer correctly without any clarification on what you mean by "hidden" (I would have asked that in a comment, but reputation you know). I'll try anyway.
What I understand is that your application creates a directory in your app directory that you don't want to see.
If you don't want to see it in the Finder/Nautilus/Windows Explorer, then the easiest way should be to name the directory beginning with period. For your example that would translate to:
FileUtils.mkdir_p '.backupFiles' unless File.exists?('.backupFiles')
This wouldn't affect the accessibility of that folder via the commandline or your app in any way. (Accept that it's name starts with a period obviously)

Maybe that might be possible using SELinux Extended Security Attributes but it sounds pretty hard to implement.
Take a look at this:
https://superuser.com/questions/738392/completely-hide-files-on-linux

Related

Associate Windows directory with program (or treat directory as file)

This is likely not a simple topic - I have researched this to the best of my abilities and realize that it is not supported in any typical fashion.
My goal is to enable something similar to .app files from OSX, where the application, as well as its user data, can exist in the same file. I imagine it would require writing a tool to manage this behaviour, but this question is more about how to achieve this in the Windows OS. I am quite flexible regarding the implementation details, but the more straightforward the behaviour, the better (i.e. avoiding copying or compressing/decompressing entire directories/archives at runtime would be ideal).
Approaches I have considered:
Find a way to get explorer to treat a directory as a file, so that it can be associated. I have found a way to get explorer to treat a directory as a control panel item, I have thus far been unable to find a way to use this to associate a custom program. See the infamous "godmode hack" for Windows (name a directory something to the effect of "GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}"). This one seems the most hopeful, but I'm at wits end trying to find information about creating a new association of this type.
Come up with some kind of archive format which can extract executable information to a temporary directory, launch this executable passing the archive as a commandline parameter. This seems like the ugliest solution, from a performance perspective. I would prefer a different solution if at all possible, one which doesn't involve making duplicates of the program or its data to run.
Find a way to associate a directory directly, though I have found no trace of this being supported in Windows, and I assume this is a dead-end.
Find a way to get an executable to include writeable embedded files. I have been unable to make any headway with this- I even tried a resource hacker approach, but obviously you cannot modify the assembly while its in use.
Tried to make a self-modifying JAR file with Java, but the route I took would add the JDK as a runtime requirement, which seems a bit overkill. Even then, it would be limited to Java, and I'm pretty sure it's not actually supposed to allow that in the first place.
Modify Windows Explorer. I shudder at the amount of work this would take, not to mention the at-best gray area it falls under legally. Perhaps there's a way to extend explorer to achieve this, I'm not sure.
A custom archive file. This seems like the most straightforward way to do it. But it would ideally need to be an archive format that has very little overhead for file I/O. Could even be some kind of virtual disk that gets mounted, but I am imagining that would be pretty heavy.
I would appreciate any insight that anyone has on this topic. I won't go into reasons as they are irrelevant to the question itself- I'm aware it is likely not the most practical solution to anything in particular. Consider it a novel pursuit.
It can be done by application virtualization,
Read this wikipedia page theory:
https://en.wikipedia.org/wiki/Portable_application
https://en.wikipedia.org/wiki/Application_virtualization
And two pages about software:
https://en.wikipedia.org/wiki/VMware_ThinApp
https://en.wikipedia.org/wiki/Turbo_(software)
Windows 7 added the ability for a Desktop.ini file to add/change the folder verbs on a per-folder basis. Using that trick it is possible to create a "folders as applications" style setup.

User changeable shortcuts

I've created a simply toolbox/dashboard in Visual Studio Express in VB for my work that contains links to all of the software and shortcuts we use on a day-to-day basis (see the image below, company name/app names covered to protect the innocent :p)
This was originally created for just me, then I modified the code to work on my co-workers computer. The changes that needed modifying were the addresses for each of the apps. Say, for example, App 1 is directly on the C:\ drive for me, but for my co-worker it is buried in C:\Program Files\blah blah blah. I would have to go in and hard code that path for each and every differing app path, and then if something happens and the path changes, I have to recode it again before deploying it.
What I would like to do it something where the user can modify the path so all I have to do is deploy the executable and the user can modify the path on their own. What would be the best way to accomplish this? Would it be best to have the executable look for a text file to read from/write to? Is there an easier and more effective way to do this? I'm open to any suggestions at this point
If you shellexecute just the program name, it will be looked up in the AppPaths registry key. See HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths. Plus it will open anything. If you want to open a text file a.txt, register it as a.exe. Typing a will run the command (notepad c:\somewhere\a.txt).

Updating Batch files via Dropbox

So, there isn't anything big that I'm really going to use this for, but I've have made a little batch (.bat) program that I thought would be awesome if I had this feature in it.
I don't want anything that is going to mess up my LAN network, so try to make it as simple
as possible.
So my idea is that I want it so when the program starts it scans for an update (which will be found on Dropbox), then ask the user if they want to update, then it will install an update file and delete the old one. If anyone knows a way to do this safely, please tell me, thanks!
I have a tiny bit of an idea on how this is possible, but it is not very efficient. Thanks!
I assume you have a file on your computer and one on Dropbox and sometimes you want to edit it from another computer and then when you get back home and start up the program it will check whether the Dropbox file is more up to date than the one you have on your computer?
I think the easiest way would be to either use a special file name, like, myBatchFile_update.bat or something and then make your program check for that file in your Dropbox folder. If it's there, copy it and then rename it to myBatchFile.bat or something. Also rename update file. You may want to look up copy and xcopy and ren, first.
Another way would be to keep the "if updated" information inside of the file in a function (although it's hardly functions in batch). Or you could just keep another file called for example is_updated.bat where you keep information about whether it's updated or not. You echo something like set update=true (if it's updated) to the update file when it has updated and when you have edited the program you also edit the update file so that it says false. Then, when you need the information, you just call the update file.

Application's data folder in Mac

What is the equivalent of Window's C:\Users\userName\AppData\Roaming\appName?
I need a directory that won't cause permission problems to store the updateable part
of my application so I can automatically download and override my content.
Thank you.
/Users/USERNAME/Library/Application Support/
Edit:
This answer has drawn a lot of upvotes despite its minimalistic nature. Therefore, I want to point out the things mentioned in the comments here to make them more visible:
There are several other folders being used for application data / configuration, as mentioned in this answer.
If writing an application, don't hardcode that path. Instead, use macOS' API to retrieve it. This question has several answers for both ObjectiveC and Swift.
~/Library/Application Support/
in shift+command+G in finder

Is there a counterpart of Mac OS-X filesystem bundles on Windows?

What I need is a directory which the user can handle as a single file in the Windows explorer. Does something like this exist? If not, what comes closest?
The closest thing is probably Alternate Data Streams, although those are more akin to MacOS Named Forks than Bundles.
There are also some special cases, for example if you save a website with Internet Explorer you get an HTML file and a folder which are linked together.
Depends on your particular needs. As mentioned above, named streams are possible (on NTFS), however you should notice that not all applications copy files with named streams correctly. In some scenarios regular ZIP archives can work (Explorer shows them as folders). If you are doing software development, there exist libraries that let you store many files in one container file (eg. SolFS).
I think you can create a folder with an extension, e.g. Myfolder.bundle, then you can associate that extension with a custom icon. So it looks like a bundle as far as the end user is concerned.

Resources