Technische Hochschule Würzburg-Schweinfurt (THWS)

Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Portfolio Assignment 05 – System-oriented Programming

1. Project Overview

This project is a simplified implementation of the Linux ls command, capable of listing, filtering, and sorting files and directories.

Features:

  • -R (Recursive listing)
  • -a / -A (Show/hide hidden files)
  • -l (Detailed output)
  • --sort=name|size|time (Sorting options)
  • --reverse (Reverse sorting order)
  • --name=PATTERN (Filter by name with wildcards)
  • --type=f|d (Filter by file or directory)

The program is written in C and ensures thread-safe execution using mutex locks within its dynamic data structure.


2. Project Structure

📂 project_root
 ├── 📂 src            # Contains all source and header files
 │   ├── main.c / main.h
 │   ├── display.c / display.h
 │   ├── dataStructures.c / dataStructures.h
 │   ├── options.c / options.h
 │   ├── thread_utils.c / thread_utils.h
 │   ├── filterUtils.c / filterUtils.h
 │   ├── generic_list.c / generic_list.h
 │   ├── test.c / test.h
 │   Makefile         # Describes the build process 
 ├── README.md        # This file

3. Build and Installation

This project uses GCC and a Makefile for compilation.

:wrench: Requirements

  • Linux with GCC
  • Make (for build automation)

:package: Build Instructions

  1. Navigate to the project directory:
    cd project_root
  2. Compile the program:
    make 
    This generates the executable MyLS in the build folder (same as make all).
  3. Clean up compiled files:
    make clean

4. Usage

Run the program with different options:

./MyLS [OPTIONS] [DIRECTORY]

Examples:

  • List files: ./myls
  • Recursive listing: ./myls -R
  • Show hidden files: ./myls -a
  • Sort by size: ./myls --sort=size --reverse
  • Filter by *.txt files: ./myls --name=*.txt
  • Show only directories: ./myls --type=d