This commit is contained in:
Guillem George 2025-10-24 23:16:13 +02:00
parent ce214b8bbd
commit 9dabdcfbfd
5 changed files with 82 additions and 1 deletions

9
.gitignore vendored
View file

@ -1,2 +1,9 @@
a.out
*.out
*~
*.swp
*.o
*.a
*.so
*.class
*.log
*.core

3
micromake/src/Microfile Normal file
View file

@ -0,0 +1,3 @@
qwertyu:
cbejw: a bc d
dmwq :d wdwd

3
minimake/Makefile Normal file
View file

@ -0,0 +1,3 @@
CC= gcc
CFLAGS= -std=c99 -pedantic -Werror -Wall -Wextra -Wvla

31
minimake/minimake.c Normal file
View file

@ -0,0 +1,31 @@
// Error Codes
#define INVALID_ARG 2
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
// TODO:
// Look at perror for stdlib functions
// Create an enum for error handling
int handle_args(int argc, char **argv)
{
int flags = 0;
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "-h"))
errx(INVALID_ARG, "-h: not implemented");
else if (strcmp(argv[i], "-f"))
errx(INVALID_ARG, "-f: not implemented");
else if (strcmp(argv[i], "-p"))
errx(INVALID_ARG, "-p: not implemented");
else
errx(INVALID_ARG, ": Pleaase give an argument");
}
}
int main(int argc, char **argv)
{}

37
simple_ls/simple_ls.c Normal file
View file

@ -0,0 +1,37 @@
#include <dirent.h>
#include <err.h>
#include <stdio.h>
static void simple_ls(char *path)
{
if (path == NULL)
errx(1, "Internal error: Passed NULL path");
DIR *dir = opendir(path);
if (dir == NULL)
errx(1, "Internal error: cannot open directory");
struct dirent *element;
while ((element = readdir(dir)))
{
puts(element->d_name);
}
int res = closedir(dir);
if (res == -1)
errx(1, "Could not close dir");
}
int main(int argc, char **argv)
{
if (argc < 2)
simple_ls(".");
else
{
for (int i = 1; i < argc; i++)
{
simple_ls(argv[i]);
}
}
return 0;
}