feature/max abgeschlossen
- Verzeichnistiefe und maximale Anzahl an Dateien über Parameter steuerbar - weitere Features implementiert wie Laufzeitmessung
This commit is contained in:
parent
7dd51d3ebd
commit
fc219ceac1
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,6 +1,17 @@
|
|||||||
# Changelog: treeScanner.exe
|
# Changelog: treeScanner.exe
|
||||||
|
|
||||||
- **11-05-25 - v1.0.1** [UNCOMMITET]
|
- **2025-05-14 - v1.1.0**
|
||||||
|
|
||||||
|
- **Hinzugefügt:**
|
||||||
|
- [x] Laufzeitmessung per `GetTickCount64()` in `main.c`
|
||||||
|
- [x] Ausgabe der Gesamtzeit in Millisekunden nach Scanabschluss
|
||||||
|
- [x] `scanner_config.h/.c` mit `ScannerConfig`-Struktur für zentrale Parameterverwaltung
|
||||||
|
- [x] CLI-Parameter `--depth` für maximale Verzeichnistiefe (`main.c`)
|
||||||
|
- [x] CLI-Parameter `--limit` für max. Dateien pro Verzeichnis (`main.c`)
|
||||||
|
- [x] Erweiterung von `scan_directory()` zur Einhaltung der Limits (`app.c`)
|
||||||
|
- [x] Neue Funktionssignatur in `app.h`: Übergabe der Konfiguration
|
||||||
|
|
||||||
|
- **2025-05-11 - v1.0.1**
|
||||||
- [x] `favicon.ico` erstellt und hinzugefügt
|
- [x] `favicon.ico` erstellt und hinzugefügt
|
||||||
- [X] `desktop.ini` erstellt
|
- [X] `desktop.ini` erstellt
|
||||||
- [x] `version.rc`erstellt und `build.cmd`entsprechend angepasst das Metadaten compiliert werden
|
- [x] `version.rc`erstellt und `build.cmd`entsprechend angepasst das Metadaten compiliert werden
|
||||||
|
29
Makefile
29
Makefile
@ -1,32 +1,39 @@
|
|||||||
# Haupt-Makefile
|
# Makefile – Buildsystem für scanner.exe unter MSVC
|
||||||
|
# Aufruf über build.cmd (ruft vcvars64.bat auf) → dann make
|
||||||
|
|
||||||
|
# Zentrale Konfiguration laden
|
||||||
include Makefile.config
|
include Makefile.config
|
||||||
|
|
||||||
# Wenn DEBUG=1 gesetzt ist: zusätzliche Flags anhängen
|
# Standardziel
|
||||||
ifeq ($(DEBUG),1)
|
|
||||||
CFLAGS = $(BASE_CFLAGS) /Zi /Od /DDEBUG
|
|
||||||
LDFLAGS = $(BASE_LDFLAGS) /DEBUG /PDB:$(OUTDIR)\scanner.pdb
|
|
||||||
|
|
||||||
else
|
|
||||||
CFLAGS = $(BASE_CFLAGS) /O2
|
|
||||||
LDFLAGS = $(BASE_LDFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: $(EXE)
|
all: $(EXE)
|
||||||
|
|
||||||
|
# ---- Kompilieren der Quellcodedateien ----
|
||||||
|
|
||||||
|
# main.c → main.obj
|
||||||
$(OUTDIR)\main.obj: $(SRCDIR)\main.c
|
$(OUTDIR)\main.obj: $(SRCDIR)\main.c
|
||||||
@if not exist $(OUTDIR) mkdir $(OUTDIR)
|
@if not exist $(OUTDIR) mkdir $(OUTDIR)
|
||||||
$(CC) $(CFLAGS) /c /Fo:$@ $<
|
$(CC) $(CFLAGS) /c /Fo:$@ $<
|
||||||
|
|
||||||
|
# app.c → app.obj
|
||||||
$(OUTDIR)\app.obj: $(SRCDIR)\app.c
|
$(OUTDIR)\app.obj: $(SRCDIR)\app.c
|
||||||
$(CC) $(CFLAGS) /c /Fo:$@ $<
|
$(CC) $(CFLAGS) /c /Fo:$@ $<
|
||||||
|
|
||||||
|
# scanner_config.c → scanner_config.obj
|
||||||
|
$(OUTDIR)\scanner_config.obj: $(SRCDIR)\scanner_config.c
|
||||||
|
$(CC) $(CFLAGS) /c /Fo:$@ $<
|
||||||
|
|
||||||
|
# Ressourcen-Datei → version.res
|
||||||
$(RES): $(RESDIR)\version.rc
|
$(RES): $(RESDIR)\version.rc
|
||||||
$(RC) /nologo /fo $@ $<
|
$(RC) /nologo /fo $@ $<
|
||||||
|
|
||||||
|
# ---- Linken der Executable ----
|
||||||
|
|
||||||
|
# Alle Objektdateien + Ressourcen → scanner.exe
|
||||||
$(EXE): $(OBJ) $(RES)
|
$(EXE): $(OBJ) $(RES)
|
||||||
$(LINK) $(LDFLAGS) $(OBJ) $(RES)
|
$(LINK) $(LDFLAGS) $(OBJ) $(RES)
|
||||||
|
|
||||||
|
# ---- Aufräumen ----
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@if exist $(OUTDIR) del /Q $(OUTDIR)\*.*
|
@if exist $(OUTDIR) del /Q $(OUTDIR)\*.*
|
||||||
@if exist vc140.pdb del vc140.pdb
|
@if exist vc140.pdb del vc140.pdb
|
||||||
|
@ -1,21 +1,30 @@
|
|||||||
# Makefile.config – zentrale Konfigurationsdatei für MSVC-Build
|
# Makefile.config – zentrale Buildkonfiguration
|
||||||
# Toolchain
|
|
||||||
|
# Tools
|
||||||
CC = cl
|
CC = cl
|
||||||
RC = rc
|
RC = rc
|
||||||
LINK = link.exe
|
LINK = link.exe
|
||||||
|
|
||||||
# Pfade
|
# Verzeichnisse
|
||||||
OUTDIR = build\output
|
|
||||||
INCLUDEDIR = include
|
|
||||||
SRCDIR = src
|
SRCDIR = src
|
||||||
RESDIR = resources
|
RESDIR = resources
|
||||||
|
OUTDIR = build\output
|
||||||
|
INCLUDEDIR = include
|
||||||
|
|
||||||
# Source-Dateien
|
# Flags
|
||||||
SRC = $(SRCDIR)\main.c $(SRCDIR)\app.c
|
BASE_CFLAGS = /nologo /W4 /I $(INCLUDEDIR)
|
||||||
OBJ = $(OUTDIR)\main.obj $(OUTDIR)\app.obj
|
BASE_LDFLAGS = /nologo /SUBSYSTEM:CONSOLE /OUT:$(OUTDIR)\scanner.exe
|
||||||
|
|
||||||
|
# Debug-abhängige Erweiterungen
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
CFLAGS = $(BASE_CFLAGS) /Zi /Od /DDEBUG
|
||||||
|
LDFLAGS = $(BASE_LDFLAGS) /DEBUG /PDB:$(OUTDIR)\scanner.pdb
|
||||||
|
else
|
||||||
|
CFLAGS = $(BASE_CFLAGS) /O2
|
||||||
|
LDFLAGS = $(BASE_LDFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Quell- und Ausgabedateien
|
||||||
|
OBJ = $(OUTDIR)\main.obj $(OUTDIR)\app.obj $(OUTDIR)\scanner_config.obj
|
||||||
RES = $(OUTDIR)\version.res
|
RES = $(OUTDIR)\version.res
|
||||||
EXE = $(OUTDIR)\scanner.exe
|
EXE = $(OUTDIR)\scanner.exe
|
||||||
|
|
||||||
# Standard-Flags (werden dynamisch erweitert)
|
|
||||||
BASE_CFLAGS = /nologo /I $(INCLUDEDIR)
|
|
||||||
BASE_LDFLAGS = /nologo /SUBSYSTEM:CONSOLE /OUT:$(EXE)
|
|
||||||
|
140
README.md
140
README.md
@ -1,5 +1,7 @@
|
|||||||
# ⚙️ CLI-Template für C (MSVC)
|
# ⚙️ CLI-Template für C (MSVC)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Ein leichtgewichtiges C-Projekttemplate für die Kommandozeile unter Windows, vorbereitet für den Microsoft Visual C Compiler (MSVC).
|
Ein leichtgewichtiges C-Projekttemplate für die Kommandozeile unter Windows, vorbereitet für den Microsoft Visual C Compiler (MSVC).
|
||||||
|
|
||||||
## Inhalt
|
## Inhalt
|
||||||
@ -9,19 +11,28 @@ Ein leichtgewichtiges C-Projekttemplate für die Kommandozeile unter Windows, vo
|
|||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Struktur](#struktur)
|
- [Struktur](#struktur)
|
||||||
- [Voraussetzungen](#voraussetzungen)
|
- [Voraussetzungen](#voraussetzungen)
|
||||||
|
- [Compiler (MSVC)](#compiler-msvc)
|
||||||
|
- [Make (empfohlen: MSYS2)](#make-empfohlen-msys2)
|
||||||
- [Nutzung](#nutzung)
|
- [Nutzung](#nutzung)
|
||||||
|
- [Build](#build)
|
||||||
|
- [Optionen](#optionen)
|
||||||
- [Dokumentation](#dokumentation)
|
- [Dokumentation](#dokumentation)
|
||||||
- [Plattformhinweis](#plattformhinweis)
|
- [Plattformhinweis](#plattformhinweis)
|
||||||
|
- [Geplante Features](#geplante-features)
|
||||||
|
- [Lizenz](#lizenz)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Rekursive Verzeichnissuche mit ASCII-Ausgabe
|
- Rekursive Verzeichnissuche mit Unicode-Symbolen (📁 📄)
|
||||||
- Kompatibel mit `cl.exe` über `build.cmd`
|
- Optionale Tiefenbegrenzung via `--depth N`
|
||||||
- Debugging per `launch.json` (VS Code)
|
- Limitierung der Dateiausgabe pro Verzeichnis via `--limit N`
|
||||||
- Unicode-Ausgabe (📁 📄) für unterstützende Terminals
|
- Unicode-fähige Konsolenausgabe auf Windows (`SetConsoleOutputCP`)
|
||||||
- Struktur für sauberen Code (main + Module)
|
- Debugging vorbereitet via `launch.json` (VS Code)
|
||||||
|
- Sauber modularisierter Code (main + Module + Config)
|
||||||
|
- MSVC-kompatibles Buildsystem (`cl.exe` + `rc.exe` + `link.exe`)
|
||||||
|
- Unterstützt `Makefile` + `Makefile.config` für Debug/Release
|
||||||
|
|
||||||
[⚓](#inhalt)
|
[⚓](#inhalt)
|
||||||
|
|
||||||
@ -29,39 +40,29 @@ Ein leichtgewichtiges C-Projekttemplate für die Kommandozeile unter Windows, vo
|
|||||||
|
|
||||||
## Struktur
|
## Struktur
|
||||||
|
|
||||||
Alle notwendigen Verzeichnisse und Dateien wurden mit ✅ markiert, diese sind unverzichtbar für das Projekt.
|
Alle notwendigen Verzeichnisse und Dateien wurden mit ✅ markiert, diese sind unverzichtbar für den Buildprozess.
|
||||||
Ohne diese, ist ein compilieren nicht möglich.
|
❌ markiert alles, was optional ist oder ignoriert werden kann.
|
||||||
Dateien und Verzeichnisse die mit ❌ markiert wurden, können theoretisch gelöscht werden und für den Buildprozess nicht notwendig.
|
|
||||||
|
|
||||||
```plaintext
|
```plaintext
|
||||||
📁 treescanner # Projekt-Wurzelverzeichnis (Repository-Root)
|
📁 treescanner
|
||||||
📁 .vscode # ❌ Konfigurationsverzeichnis für Visual Studio Code
|
📁 .vscode # ❌ VS Code-Konfiguration (Debug, Build, Editor-Style)
|
||||||
📄 c_cpp_properties.json # ❌ IntelliSense-Einstellungen (Compilerpfade, Defines etc.)
|
📄 launch.json # ❌ Debug-Konfiguration (z. B. scanner.exe + Breakpoints)
|
||||||
📄 extensions.json # ❌ Empfehlung installierbarer VS Code Extensions
|
📄 tasks.json # ❌ Build-Task für Make unter Windows
|
||||||
📄 launch.json # ❌ Debug-Konfiguration (z. B. Programm, Argumente, Terminal)
|
📁 build # ✅ Buildverzeichnis
|
||||||
📄 settings.json # ❌ Editor-spezifische Projekteinstellungen (z. B. Tabs, Formatierung)
|
📁 output # ✅ Kompilierte .exe und .obj-Dateien
|
||||||
📄 tasks.json # ❌ Build-Tasks (z. B. MSVC Build über build.cmd)
|
📁 include # ✅ Header-Dateien
|
||||||
📁 build # ✅ Build-Artefakte (ausgabeorientiertes Verzeichnis)
|
📄 app.h # ✅ Schnittstelle für scan_directory()
|
||||||
📄 .gitkeep # ❌ Platzhalterdatei, damit Git leere Verzeichnisse behält
|
📄 scanner_config.h # ✅ Konfiguration für Tiefen-/Limitsteuerung
|
||||||
📁 output # ✅ Output-Ordner für kompilierte Binärdateien und Objekte
|
📁 resources # ✅ Ressourcen wie version.rc
|
||||||
📄 app.obj # ❌ Objektdatei aus app.c
|
📄 version.rc # ✅ Icon- und Versionsdefinition
|
||||||
📄 main.obj # ❌ Objektdatei aus main.c
|
📁 src # ✅ Quellcode (.c-Dateien)
|
||||||
📄 treescanner.exe # ❌ Kompilierte lauffähige .exe-Datei
|
📄 main.c # ✅ Einstiegspunkt mit Argumentverarbeitung
|
||||||
📁 doc # ❌ Dokumentation und Templates
|
📄 app.c # ✅ rekursiver Verzeichnisscan (Windows API)
|
||||||
📁 media # ❌ Dateien für GitHub und Dokumentation
|
📄 scanner_config.c # ✅ Initialisierung und Verwaltung der Konfiguration
|
||||||
📁 resources # ✅ Dateien die zum compilieren benötigt werden (Icon, Metadaten etc.)
|
📄 build.cmd # ✅ Buildskript (ruft `vcvars64.bat` und `make` auf)
|
||||||
📁 include # ✅ Header-Dateien für Funktionsprototypen
|
📄 clean.cmd # ✅ Löscht `/build/output` + ggf. `.pdb`
|
||||||
📄 app.h # ✅ Deklaration von `scan_directory()`
|
📄 README.md # ❌ Diese Datei
|
||||||
📄 LICENSE # ❌ Lizenzdatei (hier: MIT License)
|
📄 .gitignore # ❌ Ignoriert z. B. *.obj, *.pdb, /build/
|
||||||
📄 README.md # ❌ Projektdokumentation (Nutzung, Build, Features etc.)
|
|
||||||
📁 src # ✅ Quellcode-Verzeichnis (.c-Dateien)
|
|
||||||
📄 app.c # ✅ Implementierung der rekursiven Verzeichnissuche
|
|
||||||
📄 main.c # ✅ Einstiegspunkt (main-Funktion)
|
|
||||||
📄 VERSION # ❌ Datei mit Versionsnummer (z. B. „0.1.0-dev“)
|
|
||||||
📄 .gitattributes # ❌ Git-spezifische Datei (z. B. Zeilenenden, Binärdateien, Sprache)
|
|
||||||
📄 .gitignore # ❌ Liste auszuschließender Dateien und Verzeichnisse (z. B. *.exe, /build/)
|
|
||||||
📄 build.cmd # ✅ Build-Skript für MSVC (ruft cl.exe via vcvars64.bat)
|
|
||||||
📄 clean.cmd # ❌ Hilfsskript zum Löschen von build/output
|
|
||||||
```
|
```
|
||||||
|
|
||||||
[⚓](#inhalt)
|
[⚓](#inhalt)
|
||||||
@ -70,16 +71,14 @@ Dateien und Verzeichnisse die mit ❌ markiert wurden, können theoretisch gelö
|
|||||||
|
|
||||||
## Voraussetzungen
|
## Voraussetzungen
|
||||||
|
|
||||||
### Compiler
|
### Compiler (MSVC)
|
||||||
|
|
||||||
#### MSVC
|
|
||||||
|
|
||||||
- [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
|
- [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
|
||||||
- MSVC `cl.exe` + `vcvars64.bat` korrekt eingebunden
|
- Umgebung wird über `vcvars64.bat` gesetzt
|
||||||
|
|
||||||
### Make (empfohlen: MSYS2)
|
### Make (empfohlen: MSYS2)
|
||||||
|
|
||||||
- [x] MSYS2 -> <https://www.msys2.org/>
|
- [x] `make` aus MSYS2 installieren: `pacman -S make`
|
||||||
|
|
||||||
[⚓](#inhalt)
|
[⚓](#inhalt)
|
||||||
|
|
||||||
@ -87,12 +86,27 @@ Dateien und Verzeichnisse die mit ❌ markiert wurden, können theoretisch gelö
|
|||||||
|
|
||||||
## Nutzung
|
## Nutzung
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
build.cmd
|
build.cmd
|
||||||
```
|
```
|
||||||
|
|
||||||
**Ausgabe:**
|
→ erzeugt `build/output/scanner.exe`
|
||||||
`build/output/scanner.exe`
|
|
||||||
|
### Optionen
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
scanner.exe [verzeichnis] [--depth N] [--limit N]
|
||||||
|
```
|
||||||
|
|
||||||
|
Beispiele:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
scanner.exe
|
||||||
|
scanner.exe "D:\Projekte" --depth 3
|
||||||
|
scanner.exe . --limit 5
|
||||||
|
```
|
||||||
|
|
||||||
[⚓](#inhalt)
|
[⚓](#inhalt)
|
||||||
|
|
||||||
@ -100,8 +114,8 @@ build.cmd
|
|||||||
|
|
||||||
## Dokumentation
|
## Dokumentation
|
||||||
|
|
||||||
- [x] [C Code Style Guide für CLI-Projekte](./doc/code_style.md)
|
- [x] [Code Style Guide (C für CLI-Projekte)](./doc/code_style.md)
|
||||||
- [x] [Windows API Referenz – CLI-Toolkit](./doc/index.md)
|
- [x] [Windows API Referenz](./doc/index.md)
|
||||||
|
|
||||||
[⚓](#inhalt)
|
[⚓](#inhalt)
|
||||||
|
|
||||||
@ -109,9 +123,39 @@ build.cmd
|
|||||||
|
|
||||||
## Plattformhinweis
|
## Plattformhinweis
|
||||||
|
|
||||||
> ℹ️ Dieses Projekt ist aktuell auf **Windows** ausgelegt (MSVC, Windows API).
|
> ℹ️ Aktuell ausschließlich für **Windows** (MSVC / WinAPI) vorgesehen.
|
||||||
> Es enthält jedoch bereits `#ifdef _WIN32`-Konstrukte zur Vorbereitung einer plattformübergreifenden Umsetzung.
|
> POSIX-Implementierung (`opendir`, `readdir`) ist vorbereitet aber nicht aktiv.
|
||||||
> Die POSIX-Version (`opendir`, `readdir`) kann später leicht ergänzt werden.
|
|
||||||
|
[⚓](#inhalt)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Geplante Features
|
||||||
|
|
||||||
|
| Funktion / Option | Beschreibung | Status |
|
||||||
|
| -------------------------- | --------------------------------------------------------------- | ------------- |
|
||||||
|
| `--depth N` | Maximale Verzeichnistiefe | ✅ Fertig |
|
||||||
|
| `--limit N` | Max. Dateien pro Verzeichnis | ✅ Fertig |
|
||||||
|
| `--ignore DIR` | Verzeichnisse ausschließen | ⬜ Geplant |
|
||||||
|
| `--output FILE` | Ausgabedatei (Standard: `tree.md`) mit `plaintext`-Block | ⬜ Geplant |
|
||||||
|
| ASCII-Baumstruktur (`├──`) | grafische Darstellung mit Baumzeichen → **Standardmäßig aktiv** | ⬜ Geplant |
|
||||||
|
| `--no-tree-symbols` | Option zum Deaktivieren der Baumzeichensymbole | ⬜ Geplant |
|
||||||
|
| `--console` | explizite Konsolenausgabe einschalten | ⬜ Geplant |
|
||||||
|
| `--align-comments` | Ausrichtung von Kommentaren in Spalte | ⬜ Geplant |
|
||||||
|
| `--language de/en` | Sprache der Ausgaben und Zusammenfassung | ⬜ Geplant |
|
||||||
|
| Scan-Zusammenfassung | Ausgabe: `📦 23 Dateien in 5 Ordnern`, ggf. mit Pfad | ⬜ Geplant |
|
||||||
|
| Fortschrittsanzeige | Zeitgesteuerte Live-Ausgabe | ⬜ Optional |
|
||||||
|
| POSIX-Kompatibilität | Unterstützung für Linux (`opendir`, `readdir`) | ⬜ Vorbereitet |
|
||||||
|
| Symbol-Set anpassbar | Benutzerdefinierte Icons (📁, 📄 etc.) | ⬜ Optional |
|
||||||
|
| Laufzeit erfassen | Zu Benchmarkzwecken Durchlaufzeit erfassen von Start bis Ende | ✅ Fertig |
|
||||||
|
|
||||||
|
[⚓](#inhalt)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Lizenz
|
||||||
|
|
||||||
|
MIT siehe Datei [LICENSE](./LICENSE)
|
||||||
|
|
||||||
[⚓](#inhalt)
|
[⚓](#inhalt)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef APP_H
|
#ifndef APP_H
|
||||||
#define APP_H
|
#define APP_H
|
||||||
|
|
||||||
|
#include "scanner_config.h"
|
||||||
/**
|
/**
|
||||||
* @brief Recursively scans the specified directory and prints an ASCII tree.
|
* @brief Recursively scans the specified directory and prints an ASCII tree.
|
||||||
*
|
*
|
||||||
@ -11,6 +12,6 @@
|
|||||||
* @param base_path The root directory to scan
|
* @param base_path The root directory to scan
|
||||||
* @param depth Current recursion depth, used for visual indentation
|
* @param depth Current recursion depth, used for visual indentation
|
||||||
*/
|
*/
|
||||||
void scan_directory(const char *base_path, int depth);
|
void scan_directory(const char *path, int depth, const ScannerConfig *config);
|
||||||
|
|
||||||
#endif
|
#endif
|
11
include/scanner_config.h
Normal file
11
include/scanner_config.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef SCANNER_CONFIG_H
|
||||||
|
#define SCANNER_CONFIG_H
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int max_depth;
|
||||||
|
int max_files_per_dir;
|
||||||
|
} ScannerConfig;
|
||||||
|
|
||||||
|
void init_config_defaults(ScannerConfig *config);
|
||||||
|
|
||||||
|
#endif
|
BIN
media/logo-alpha-256x256.png
Normal file
BIN
media/logo-alpha-256x256.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
media/logo-alpha-512x512.png
Normal file
BIN
media/logo-alpha-512x512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 170 KiB |
11
src/app.c
11
src/app.c
@ -18,7 +18,9 @@
|
|||||||
* @param base_path Root path to scan
|
* @param base_path Root path to scan
|
||||||
* @param depth Recursion depth for indentation
|
* @param depth Recursion depth for indentation
|
||||||
*/
|
*/
|
||||||
void scan_directory(const char *base_path, int depth) {
|
void scan_directory(const char *base_path, int depth, const ScannerConfig *config) {
|
||||||
|
if (config->max_depth >= 0 && depth > config->max_depth)
|
||||||
|
return;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WIN32_FIND_DATA find_data;
|
WIN32_FIND_DATA find_data;
|
||||||
char search_path[MAX_PATH];
|
char search_path[MAX_PATH];
|
||||||
@ -31,6 +33,8 @@ void scan_directory(const char *base_path, int depth) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int file_count = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const char *name = find_data.cFileName;
|
const char *name = find_data.cFileName;
|
||||||
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
|
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
|
||||||
@ -41,8 +45,11 @@ void scan_directory(const char *base_path, int depth) {
|
|||||||
printf("📁 %s\n", name);
|
printf("📁 %s\n", name);
|
||||||
char sub_path[MAX_PATH];
|
char sub_path[MAX_PATH];
|
||||||
snprintf(sub_path, MAX_PATH, "%s\\%s", base_path, name);
|
snprintf(sub_path, MAX_PATH, "%s\\%s", base_path, name);
|
||||||
scan_directory(sub_path, depth + 1);
|
scan_directory(sub_path, depth + 1, config);
|
||||||
} else {
|
} else {
|
||||||
|
if (config->max_files_per_dir >= 0 && file_count >= config->max_files_per_dir)
|
||||||
|
continue;
|
||||||
|
file_count++;
|
||||||
printf("📄 %s\n", name);
|
printf("📄 %s\n", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
src/main.c
42
src/main.c
@ -1,28 +1,36 @@
|
|||||||
#ifdef _WIN32
|
#include <windows.h> // hinzugefügt für GetTickCount64
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "scanner_config.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Entry point of the CLI tool.
|
|
||||||
*
|
|
||||||
* Initializes UTF-8 output on Windows, then calls scan_directory()
|
|
||||||
* with the provided argument or current directory.
|
|
||||||
*
|
|
||||||
* @param argc Number of arguments
|
|
||||||
* @param argv Array of argument strings
|
|
||||||
* @return int Exit status
|
|
||||||
*/
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SetConsoleOutputCP(CP_UTF8); // Enable Unicode output on Windows
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("[INFO] 🔍 CLI Tool gestartet\n");
|
ScannerConfig config;
|
||||||
|
init_config_defaults(&config);
|
||||||
|
|
||||||
const char *pfad = (argc > 1) ? argv[1] : ".";
|
const char *pfad = ".";
|
||||||
scan_directory(pfad, 0);
|
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "--depth") == 0 && i + 1 < argc)
|
||||||
|
config.max_depth = atoi(argv[++i]);
|
||||||
|
else if (strcmp(argv[i], "--limit") == 0 && i + 1 < argc)
|
||||||
|
config.max_files_per_dir = atoi(argv[++i]);
|
||||||
|
else
|
||||||
|
pfad = argv[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n[ℹ️] 🔍 CLI Tool gestartet\n\n");
|
||||||
|
|
||||||
|
ULONGLONG start_ms = GetTickCount64();
|
||||||
|
|
||||||
|
scan_directory(pfad, 0, &config);
|
||||||
|
|
||||||
|
ULONGLONG end_ms = GetTickCount64();
|
||||||
|
printf("\n[ℹ️] ⌛ Laufzeit des Scans: %llu ms\n\n", end_ms - start_ms);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
6
src/scanner_config.c
Normal file
6
src/scanner_config.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "scanner_config.h"
|
||||||
|
|
||||||
|
void init_config_defaults(ScannerConfig *config) {
|
||||||
|
config->max_depth = -1; // unbegrenzt
|
||||||
|
config->max_files_per_dir = -1; // unbegrenzt
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user