Hell everyone, i am trying to write a program for work, i am doing an internship there, where the program will list all the files on the Unix Server(soloaris 9) for all the engineers to look at. The code i have so far works to display all files, but the program also needs to check and see if the file is being used by another user, and if thats the case, just copy the file into there test folder where they can only read it, not edit it. If it is not being used, then the engineer will be able to copy the file onto there seat. I have never really programmed in C, so this is why i am asking for help. Thanks for all your time, and here is my code that works to display all files on the server.
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
int main(void)
{
DIR *dir = opendir(".");
if(dir)
{
struct dirent *ent;
while((ent = readdir(dir)) != NULL)
{
puts(ent->d_name);
}
}
else
{
fprintf(stderr, "Error opening directory\n");
}
return 0;
}