I have a 200mb zip file, which I want to extract to a temporary folder for processing. I have experience with rubyzip library before. However it seems that extracting all files using it is a bit of pain according to this blog post, needing to create directory before extracting individual files:
Is there an easier way to extract all things into a directory? It needs to work on both Mac OS X and Linux, but would be better if the solution is truly cross-platform.
Linux has a command line utility called unzip that will do it, IIRC. If that utility is available on Mac OS then you can just call it from ruby using system() or back ticks.
Related
I've written a command-line application that allows me to copy certain files to and from the Desktop. And up until now it's been fine since I was on Ubuntu, but now I'm adding a Windows 7 machine that doesn't play well with my current implementation.
My current solution is to duplicate my scripts and hard code paths.
CANVAS_DIR = "#{HOME}/GitHub/canvas"
gets replaced with:
CANVAS_DIR = "C:\\Users\\wurde\\GitHub\\canvas"
I've read that I should avoid hard coding paths and instead use joins. Is that the best way? If so, how does that look implemented?
Looking at the File API in Ruby I think I have the a working join solution. The important bit was to include the home directory via environment variable.
CANVAS_DIR = File.join(ENV['HOME'], 'GitHub', 'canvas')
I want to transfer files From A folder to B folder.But I want to just transfer last modifed date changed files, is it possible?
thanks
You haven't provided details of the operating system you're using, but assuming it's Linux or Mac you could use rsync.
Have a look at this thread which gives a couple of examples: http://hintsforums.macworld.com/showthread.php?t=100176
If you're on Windows, SyncBack or DeltaCopy software programs might be a good solution.
I need to write a small script that renames some files in a directory. This script needs to be run on Mac and Windows.
What is the best scripting language for this? I want to write something that runs just by calling it and there is no need to install anything else.
For example, writing a Perl script and compiling it to run on Windows and then compiling it to run on Mac. Can I do this?
Any other, more elegant solution?
Nothing matches your criteria. You will need to install something (e.g. perl) if you want something that runs on both systems.
If you had perl on both systems, you could indeed write a program that runs on both. You wouldn't even need two binaries as you suggest since Perl programs are distributed as source. (perl compiles them when it loads them, and even then, they are compiled to the same form on all systems.)
I have a build script where i create a text report file and output various log type stuff to it. The data is all being built onto an external hd which (according to 'mount') has file format "fuseblk" (which i've never heard of).
The building all seems to work ok but my report files are being saved as executables, which linux interprets as SOR files. I'd like them to just be regular text files, openable by default in my regular text editor.
I'm making the file, and writing to it, like this:
#report = File.open(File.join(DESTINATION_BUILD_FOLDER, "#{title.folder_name}_report.txt"),"w")
...
s = "making modules folder inside resource_library folder";puts s; #report.puts s
...
#report.close
I've done this lots of times before and never encountered this problem. Any ideas anyone?
cheers, max
ps i know that i can edit the saved files to make them non-executable, my question is 'why is this happening in the first place?'. Cheers :)
I don't think there's anything wrong with your program. The fuseblk just means it's being mounted through FUSE, which allows filesystem drivers to run as userspace programs, instead of kernel modules. Most likely, the filesystem is NTFS or FAT32.
The problem here is that Linux is assuming everything on the drive has the execute bit set. This is because neither NTFS nor FAT32 have the capability to store Linux permission bits (NTFS has a very different permissions system, FAT32 has virtually none). And I bet you're trying to double-click on the log files in something like the gnome file explorer, right?
Well, go there with the command line and use less or your favorite command-line editor to view them. Or right click on them in the file explorer, or open them with File -> Open from a text editor. If you ask your question to people who know Gnome (or KDE?) better, you'll probably get a better answer.
All the info I can find about burning cd's is for Windows, or about full programs to burn cd's.
I would however like to be able to burn an Audio CD directly from within my program.
I don't mind using Cocoa or Carbon, or if there are no API's available to do this directly, using a command-line program that can use a wav/aiff file as input would be a possibility too if it can be distributed with my application.
Because it will be used to burn dj mixes to cd, it would also be great if it is possible to create different tracks without a gap between them.
Command:
drutil burn -audio /path/to/folder
Check out the Apple-supplied drutil command. If you need more flexibility, the DiscRecording Framework is documented here.