aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/config.go b/config.go
index 1ec7207..8ba30ad 100644
--- a/config.go
+++ b/config.go
@@ -3,6 +3,7 @@ package main
import (
"bufio"
"os"
+ "reflect"
"sync"
"go.lindenii.runxiyu.org/lindenii-common/misc"
@@ -50,3 +51,19 @@ func prepare_dirs() error {
}
return nil
}
+
+// clean_up_dirs closes all directories. It should only be called before
+// program exit.
+func clean_up_dirs() {
+ directories_mutex.Lock()
+ defer directories_mutex.Unlock()
+ directories_rv := reflect.ValueOf(directories)
+ directories_rt := directories_rv.Type()
+ for i := range directories_rt.NumField() {
+ dir, ok := directories_rv.Field(i).Interface().(misc.Dir_t)
+ if !ok {
+ panic("directories contains a field that's not misc.Dir_t")
+ }
+ dir.Close()
+ }
+}