On Thu, 30 Jun 2005 12:53:20 +0000, Angelos wrote:
Hello.. I am trying to make a filesystem management script. I want to
display a list of files and directories and be able to delete them from
this list....
I made a search on the net and there are loads of them but I am trying to
do something much more simple.
At the moment I can display everything within a folder but if I click on a
directory it won't go into the directory, listing all contents ... it is
just a link.
Does anyone know any Tutorial page or if there is any function for
directories navigation ?
You mean the
bool chdir(path);
function.
Example from the manual,
// current directory
echo getcwd() . "\n";
chdir('public_html');
// current directory
echo getcwd() . "\n";
But that isn't what you want to know really. What you really want to know
for your application is how to collect directories and files, you don't
need to change directory to collect those.
Three methods,
The first is preferred for speed when collection has to be at the time
your code is ran. It collects as needed. So as your code looks in each
directory it collects the file information you want, acts on it in what
ever way your application needs, but goes no further until it is told, as
in browsing say or triggered from code, but not a continuous collection
process.
The second, and worst of the three, is a full collection process at the
time your code is ran. Try that on your ISP's site and they are likely to
send the boys round to see you.
Last, if you do need a full system tree/file list then consider doing this
outside of your script. A cron job in c/c++/perl ... You could have it as
a plain text file of directories that your code can use, or have it update
a MySQL database. Then it's all available for use in a similar way to
'locate' database.
The way I see it, if you have an overnight script going to all the trouble
of collecting dirs/files then it might as well pick out other information
ready for quick use in utility code, to save having it go and look at the
file itself, if your application allows.
So a suggestion for fields might be,
ID
dirpath - Directory path
filename - file name
type - File type
size - file size
created - created date
accessed - accessed date
owner - Owner
backupname - I used a name modifier for versions of documents. In my case
I make use of the year-week number - week day information of the time it
was last changed.