a little project i need some help with

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;

}

Is the file open? Depending on your permissions - if your code is going to be run by the root user, it's not too bad. Some UNIXes have lsof which helps.

What OS?

im not sure how to answer your question, but basically need to list all files on the server, if file is open, being used by someone, then we only want them to copy it to their seat with read only, if its not being used, then we want them to copy it on there seat with full permissions. OS is solaris 8, some are 9. thanks

dont mind this post i accidently repeated it