Lab8 1
Lab8 1
DIRECTORIES
LAB # 08
Fall 2024
CSE-302L
Systems Programming Lab
“On my honor, as student of University of Engineering and Technology, I have neither given
nor received unauthorized assistance on this academic work.”
Submitted to:
Dr. Madiha Sher
Friday, November 29, 2024
Result or Output/ 100% target has 75% target has 50% target has None of the
Completion of target in Lab been completed been completed been completed outputs are
PLO9 and well and well but not well correct.
formatted. formatted. formatted.
Overall, Knowledge Demonstrates Demonstrates Has partial idea Has poor idea
PLO10, excellent good knowledge about the Lab and about the Lab and
knowledge of lab of lab procedure procedure
followed followed
Attention to Lab Report Submission of Lab Submission of Late Submission Late Submission
PLO4, Report in Proper Lab Report in with proper very poor
Time i.e., in next proper time but documentation. documentation
day of lab, with not with proper
proper documentation.
documentation.
Instructor:
if (!strcmp(directoryEntry->d_name, ".") ||
!strcmp(directoryEntry->d_name, ".."))
return 0;
printf("\t");
// print if entry is a directory or a file
S_ISDIR(entryStatistics.st_mode) ? printf("d ") :
printf("- ");
// Entry name
printf(" %s\n", directoryEntry->d_name);
return 0;
}
// ls -l
else if ((argc == 2) && (!strcmp(argv[1], "-l")))
{
printf("Directory Content Statistics:\n");
while ((directoryEntries = readdir(thisDirectory)) !=
NULL)
if (displayFileStatistics(directoryEntries) == -1)
return 1;
}
// ls file.xyz
else if (argc == 2)
{
while ((directoryEntries = readdir(thisDirectory)) !=
NULL)
if (!strcmp(directoryEntries->d_name, argv[1]))
{
printf("File Found:\n\t%s\n",
directoryEntries->d_name);
break;
}
}
// ls -l file.xyz
else if ((argc == 3) && (!strcmp(argv[1], "-l")))
{
while ((directoryEntries = readdir(thisDirectory)) !=
NULL)
if (!strcmp(argv[2], directoryEntries->d_name))
{
printf("File Found. Statistics:\n");
if (displayFileStatistics(directoryEntries) ==
-1)
return 1;
break;
}
}
return 0;
}
Output: