# include <dirent.h>
# include <stdio.h>
# include <sys/stat.h>
# include<string.h>
# include<fcntl.h>
void quit(char *,int);
char *path="/run/media/admin/"; /* Modify this line by checking your /run/media/ file i.e. username displayed on terminal*/
struct file1
{
char *filename;
} f[50];
int main()
{
DIR *dir;
int i=0,k=0,count=1;
struct dirent *direntry;
if ((dir=opendir(path))==NULL)
quit("opendir",1);
printf("\n List of connected usb to this computer: \n");
while((direntry=readdir(dir)) !=NULL)
{
if(!strcmp(direntry->d_name,".")||!strcmp(direntry->d_name,".."))
{
}
else
{
f[k].filename=direntry->d_name;
printf(" %d. %s \n",count,f[k].filename);
k++;
count++;
}
i++;
}
closedir(dir);
return 0;
}
void quit(char *message,int exit_status)
{
perror(message);
//exit(exit_status);
}
# include <stdio.h>
# include <sys/stat.h>
# include<string.h>
# include<fcntl.h>
void quit(char *,int);
char *path="/run/media/admin/"; /* Modify this line by checking your /run/media/ file i.e. username displayed on terminal*/
struct file1
{
char *filename;
} f[50];
int main()
{
DIR *dir;
int i=0,k=0,count=1;
struct dirent *direntry;
if ((dir=opendir(path))==NULL)
quit("opendir",1);
printf("\n List of connected usb to this computer: \n");
while((direntry=readdir(dir)) !=NULL)
{
if(!strcmp(direntry->d_name,".")||!strcmp(direntry->d_name,".."))
{
}
else
{
f[k].filename=direntry->d_name;
printf(" %d. %s \n",count,f[k].filename);
k++;
count++;
}
i++;
}
closedir(dir);
return 0;
}
void quit(char *message,int exit_status)
{
perror(message);
//exit(exit_status);
}
Blogger Comment
Facebook Comment