views:

54

answers:

3

I want to write an app. (web-based if possible) to copy an external HDD (already partitioned and containing data) to a like HDD with the same partitions-- does anyone think this would be possible with Java (Google App Engine? To convert Java app and run in web environment? Or likewise)

Thoughts on if anything thinks this would be possible in a certain language would be very helpful! PS. I think one of the biggest constraints would be where the data is going to land in between downloaded from one drive, and uploading to the next -- so for example I would need to establish a temp. directory on the users local internal HDD, transfer the contents of the external, than direct the final process of moving that data back out to the new external!

PS. I also know the brand, size of drive I will be using.

+5  A: 

You shouldn't be trying to do this in a webapp, IMO. You will be blocked by sandbox security restrictions if you do this in an untrusted webapp / applet. And asking users to open up security to let your app do this is too dangerous ... for them.

Bulk file copying is best done using native OS tools.

Stephen C
Yes, this would be a lot easier, but I want to limit the number of times a user can use the app. and so they would have to approve the security restrictions after they purchased a license.
jordan.baucke
Ick! If I was a customer, I think I'd be asking for my money back!!
Stephen C
this does not address the question. while many would agree with Steven C's assessment. this answer does not address the 'How To'
Brian Leahy
+1  A: 

Well, in theory you can do it in Java as a Java Applet. But the Applet must be signed and the user must approve the security restrictions for the applet. It might be problematic copying the same hard drive of the OS if you are trying to do a bit by bit copy.

If you want a bit by bit copy of the OS disc, you must boot from an external CDROM/USB Device in order to preform the copy, and then the best language to write it will be C/C++.

If you are not searching for bit by bit copy, then you can just copy the files and that's can be accomplished even using JavaScript with shell.scripting object.

aviv
jUSB in a Java Applet, assuming users were willing to approve security restrictions (don't know much about "signing" an applet -- any advice? Not sure what you mean about "bit by bit" copy, but the data will be pretty much one large block file that is designed for use with another file system-- (and I'm not trying to copy the OS disk).
jordan.baucke
A: 

You didn't specified all the requirements, but (normally) you cannot do this in an Web app because:

  • You need access rights (ok, possible but...)
  • You need speed
  • The data is changing during the copy? If yes, then how? If the files are added / deleted then you need to register a watcher on drive (which means a concrete platform-specific API callback - very unlikely to be available in any Web language - Java, PHP etc.) to see what files needs to be copied after you scanned already the place in which the new file is added / deleted. If the files can be "anything" and are modified "randomly" during the copy process then you're in trouble. Because you can copy a file which is in an inconsistent state. This case is rare but it can happen. Especially if you want to mirror some kind of special HDD (eg. the main drive - the drive with the OS on it).

Also, there are other tricks involved when the files are changing on the source disk (different applications have different storage engines which have different patterns on saving a file).

If the disks are 'frozen' then you're ok. You can do a simple file copy (but also beware if you need to copy the file attributes, file streams etc.).

But if not, I'd advise you to buy a ready made application for this task like this one.

Thanks for the replies. 1.) I've been reading about jUSB (for Java) -- since ultimately the drives will be external HDDs hooked up using a USB-SATA adapter. What do you think of this? Once I'm able to hook into the HDD using some sort of USB-host controller it will should behave like any other usb device. 2.) The file system is basically big blocks of data, a simple file structure will have to be duplicated, but I know where each partition begins and ends.3.) The reason for a web-app. was licensing really I want to control the number of copies a user can make with a license database.
jordan.baucke
So, in fact, the data **doesn't** change during the copy process?This is the crux of the problem.