Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi
I am working on a project in which I have to search '/ ' and ' /user ' directory . I have written a c++ code which works well on any other directory but when i give search directory to ' / ' or ' /user ' it displays an error "SEGMENTATION FAULT"
I think the original post is almost humorous - if you want detailed advice, how could we do anything with that level of information?
If you want the non-detailed advice:
Find the problem and fix it.
Perhaps something to think about is why a program could work on some directories and not others. Possibly, your program doesn't cope very well when directory (or file) permissions do not let it access the files/directories that are there.
You'll need it, if you aren't going to cheat by either finding the cause and putting it right, or posting a sufficient level of detail that someone else can understand what exactly what you are doing.
I will post the code on site on 27 of this month as its my term project and its deadline is on 26th of April .if I post the code now it may create many complications for me .But meanwhile I will try to find out the reason and solution to this problem .
public:
linklist(char path[])
{
head =NULL;
tail = NULL;
DIR *Test = opendir(path);
if (Test == NULL)
{
cout<<"Invalid PATH Given\n";
}
else
{
// Add Node for the Main directory
folder *temp = new folder;
strcpy(temp->folderPath,path);
temp->fileHead=NULL;
temp->nextFolder=NULL;
temp->threadAllocated = false;
head = temp;
tail = temp;
folder * current = head;
do
{
Test = opendir(current->folderPath);
// checking that if Directory specified exists
//dirent *dirTest = readdir(Test);
if (Test == NULL)
{
cout<<"End Of Directories\n";
}
else
{
char dummyPath[200];
struct dirent *selection;
while ( (selection = readdir(Test) ) != NULL)
{
strcpy(dummyPath,current->folderPath);
struct stat fstat;
if (dummyPath[ strlen(dummyPath)-1 ] != '/')
{
strcat(dummyPath,"/");
}
strcat(dummyPath,selection->d_name);
if (!(strcmp(selection->d_name,".") == 0 || strcmp(selection->d_name,"..") == 0 || stat (dummyPath,&fstat) <0 ))
{
if (S_ISDIR(fstat.st_mode) )
{
counter++;
// Add node for folder
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.