simple Tree/Linux
i have a problem with my code. It should list all directories but it seems like that it doesnt enter the if(content->d_type = DT_DIR) statement. can someone help me? yesterday it works and i dont knw what i have done wrong
the output should look like: Directory 1 file 1 file 2 Directory 2 file 1 file 2 directory 2.1 file..... Code:
#include <unistd.h> |
Not all file types will return the value. Check and see if DT_UNKNOWN is being returned in the field.
|
...or maybe just use tree itself. ;)
(man tree) |
You can also use the S_ISDIR macro from stat.h.
|
couldn't test your program:
Code:
make koxp |
I am not sure this will help you. I am writing a C# program that compares the var/www folder to a backup drive on another workstation and writes the changes to the backup drive pathB. It does a directory list from both var/www and the other drive. It reads directories, subdirectories and files. Visual studio for C# is what I wrote it in. I have used it on Linux.
http://www.scsiraidguru.com/CSharp/CopyChange.html |
Quote:
Running an M$ application to write C-{pound-sign, number-sign, octothorpe} code to do a very simple built-in operation on a GNU/Linux machine is nonsense, at best. Please do not pollute LQ threads with such noise posing as answers. To OP - as already suggested, simply use the tree command, built in on most GNU/Linux platforms: Code:
man tree |
first of all thx for all answers
I know that i could use the TREE programm itself, but this projekt is somethink like a homework. I found the mistake but now I have another problem. If I put the argument -i in the command line (:/Tree -i) I want that the programm should list me the INO_number. I know that i can use the dirent structure an make a simple if statement, but my problem is how i can use the iflag in my opendirectory funktion.. (i hate pointers ^^) |
It's unrelated to pointers, it is a logical value (yes/no).
In this case, you might use a global variable: Code:
static struct { |
so thanks for all answers . a new problem occurred and now i need help again ^^.
in this Project i have to implemnet these thinks. timeout() allow passing a maximum execution time in seconds nice() proper use of nice via commandline argument error handling (specifically permissions issues) reasonable failure information proper cleanup (memory) in case of failure so what he is meaning with these points. i dont understant that. should i use the timeout funktion or should i write a own timeout? and how i can implement this and i also dont understand how to implement the other thinks. my current code to list all directories/Files in the current directory Code:
#include <unistd.h> |
Quote:
|
his response ...
We gone through this part in the lecture, so it has to be clear what you have to do. Think 5 seconds more about it. the problem is, everyone has a different project so , i cannot ask anyone :( strange teacher i know. Firstly can you explain me how to implement a timeout in seconds? |
equals is == (2 equal signs) whereas 1 equal sign as you used in post #1 is an assignment.
OK |
All times are GMT -5. The time now is 06:06 AM. |