|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Parse a physical drive
I need to parse a physical drive and get a result similar to a [DIV /S] from the command line. I need to know how many nodes from the root each file is and the file type. Example: FileName:="TeastMe.txt" NodeCount:="14" or something. Could anyone help me please.
Thank You Eric Cashwell |
|
#2
|
|||
|
|||
|
not quite clear
It's not quite clear what are you trying to accomplish.
If what you want is to parse a string like "/home/user/public_html/welcome.html" (or similarly, "C:\home\user\public_html\welcome.html") and return something like Code:
name=welcome.html level=3 // with zero-based level number then it's a trivial task of simply searching the string for the occurence of '/' or '\'. If you're looking for a concrete implementation in a particular language, then you should probably ask it in that language's forum (I would call it bad taste to resort here to any language in particular :) If you actually want to really "parse a physical drive" and get the same result for a given file name, it would require knowledge of the underlying filesystem. Since there is a plethora of those available (among them Ext2, Ext3, NTFS, FAT[32], ReiserFS, UFS; just to mention a few), so it's impossible to answer your question. Even then, it's not a matter of algorithms, but rather a question of "specification of filesystem implementation". If your question is something completely different, then accept my apology for not knowing any better. That's it. |
|
#3
|
|||
|
|||
|
you asked in the algorithms forum, this one is easy. here you go:
(pseudo-code) Code:
global file_list;
function add_to_list(n,d,t) {
l=length(file_list);
file_list[l]->name=n;
file_list[l]->level=d;
file_list[l]->type=t;
}
function parse_dir(dirname) {
depth++;
static depth;
for each entry {
add_to_list(dirname+"\"+entry.name,depth,entry.type);
if (is it a directory) {
parse_dir(dirname+"\"+entry.name); // recursive call to get all files inside
}
}
}
parse_dir("(DRIVE LETTER):\")
does this fit to your question?
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > Parse a physical drive |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|