Skip to content

Commit

Permalink
feat: sort the list of unmanaged files
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 2c84f8257ee4606bdba3c093baa0d2e27012df0997538c12193da8b04353d2f0
  • Loading branch information
thindil committed Dec 31, 2024
1 parent a578467 commit 9ec398f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/beastcleaner.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

## The main module of the program.

import std/[os, osproc, parseopt, sets, strutils, terminal]
import std/[algorithm, os, osproc, parseopt, sets, strutils, terminal]
import contracts

proc showCommandLineHelp() {.sideEffect, raises: [], tags: [WriteIOEffect],
Expand Down Expand Up @@ -140,7 +140,8 @@ proc main() {.raises: [], tags: [ReadIOEffect, WriteIOEffect, ExecIOEffect,
quit "Can't show message."
var installedFiles: HashSet[string] = initHashSet[string]()
try:
for entry in walkDirRec(dir = "/usr/local", yieldFilter = {pcFile, pcLinkToFile}):
for entry in walkDirRec(dir = "/usr/local", yieldFilter = {pcFile,
pcLinkToFile}):
installedFiles.incl(key = entry)
except OSError:
quit "Can't create the list of all local files."
Expand All @@ -157,7 +158,11 @@ proc main() {.raises: [], tags: [ReadIOEffect, WriteIOEffect, ExecIOEffect,
except IOError:
quit "Can't create the output file."
installedFiles = installedFiles - managedFiles
var diffFiles: seq[string] = @[]
for file in installedFiles:
diffFiles.add(y = file)
diffFiles.sort(cmp = system.cmp)
for file in diffFiles:
try:
diffFile.writeLine(x = file)
except IOError:
Expand Down

0 comments on commit 9ec398f

Please sign in to comment.