Commit Graph

9 Commits

Author SHA1 Message Date
Érico Nogueira 3db1db5cf4 Close stdin on program launch.
It's unused and can give us an extra file descriptor.
2022-06-12 22:59:17 -03:00
Érico Nogueira 5b4396c4a1 Improve error handling and error messages.
- Rrror out clearly on most allocation failures (the others will simply
  segfault). Avoid getting into weird program conditions in case some
  operations fail.
- Improve organization of main(), no function pointer usage should be
  necessary.
- Make main thread also a worker thread: avoid leaving a useless thread
  around simply waiting for others to complete. Also means one less
  thread to launch.
2022-01-21 15:45:34 -03:00
Érico Nogueira fdf8fa3c30 General cleanup.
- actually print error for bad parent
- declare functions as static when necessary
- clean up headers
- clear up error message
2021-09-18 23:48:56 -03:00
Érico Nogueira 7c6fe16e7b Stop using ftw. 2021-09-18 11:23:56 -03:00
Érico Nogueira e24aef5395 Split implementation into two files.
- also fix threadings bugs: threads could leak (if the join loop exited
  due to some error) or non existent threads could be joined (we add the
  created struct member to avoid this)
2021-05-18 00:35:30 -03:00
Érico Nogueira 75c36e6432 Make recursive removal threaded. 2021-05-18 00:06:47 -03:00
Érico Nogueira 0741a2da4e Refactor into a simpler code path. 2021-05-17 23:50:24 -03:00
Érico Nogueira f3f90857e8 Implement recursion using nftw.
FTW_DEPTH gives the natural file removal order, but it doesn't lend
itself easily well to traversing the directory tree in a multi-threaded
manner.
2021-05-17 23:44:56 -03:00
Érico Nogueira 4bdc7f18c5 Initial commit.
Can delete a sequence of files of directories in the command line, no
recursion yet.

Assumes remove(3) is fast and reasonable:

   unlink(); if (errno==EISDIR) rmdir();
2021-05-17 23:29:05 -03:00