Determining type of drive a file is on

kee nethery kee at kagi.com
Mon Aug 2 17:56:47 EDT 2004


>>> Windows, I don't know, but on OS X maybe you might be able to get 
>>> something
>>> from System Profiler?
>>
>> This looks promising.  Now, is there a command line tool that gives 
>> this info in OS X...
>
> /usr/sbin/system_profiler

The goal of the OS is to make all drives appear exactly the same, as 
drives that are either writeable or not and otherwise, the apps running 
under that OS should not notice any differences between them.

What you are asking for is counter to what the OS is trying to do. 
Obviously the data is available. You'll note that Apple writes the 
system profiler and I'd guess that they probably have to modify it on a 
frequent basis to allow it to use undocumented calls to bypass what the 
OS is doing and provide you with the data that you desire when you are 
using system profiler. My guess is that someone else could write a 
similar piece of software but that they too would be constantly 
revising the various profiles in their software each time new hardware 
is released.

If I were you, I'd ask a question that every OS wants to answer rather 
than trying to ask a question about a detail that every OS tries to 
hide.

So lets step back. Why are you asking these questions? Perhaps you 
should instead, allow the user to select the drive they want? Perhaps 
you can do some educated guessing based upon read write times of a 
standard size file and based upon the relative size of various drives 
available to the system? Why do you care what kind of drive? If you are 
making assumptions about what you can do with a drive based upon what 
type it is, perhaps you should not do that because chances are good 
that your assumptions will be wrong for some percentage of your users. 
If you need to mark a drive, perhaps you let the user mark it by 
storing a file on it and instead of doing something with the USB flash 
drive, you do something with the drive that has the marker file?

On my system (a laptop) I have quite a few drives. The internal hard 
drive 37GB. A disk image that mounts onto the desktop that is actually 
stored on the laptop drive 500Mb. Two external firewire drives 15GB and 
190GB. One USB flash drive 32MB and a disk image on it that is 5MB in 
size, and a USB digital camera 256MB. One DVD read/write 4GB which can 
also be a CD R/W. And then at various times a disk image that mirrors a 
remote FTP site.

Now if I was running your software, I don't think I'd want you to make 
any assumptions about the various drives on my system. I'd want to 
specify which drives you write or store onto and which drives you run 
from. For example, the 190GB is a backup and I don't want you to do 
anything to that drive even though it appears to be the main drive if 
you base that decision upon access speed and size.

Not knowing anything about what you are attempting to do, I urge you to 
consider alternate ways of accomplishing what you are attempting to 
accomplish that are in sync with what all OSes are trying to do. Trying 
to go against the OS is never a long term solution.

Just my two cents and worth every penny you paid for it.

kee nethery



More information about the use-livecode mailing list