aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-12-09 20:33:40 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-12-09 20:33:40 +0100
commit67596a81532149615bae07c47f81db2e1c7f7e28 (patch)
tree98677b5b2b8a6c57df68dfdff482a3b5e2a473cd /cmd
parent8a00d7064bb1ec6e3fda57f5e3d72cda9e7bcc5b (diff)
downloadpdf-simple-sign-67596a81532149615bae07c47f81db2e1c7f7e28.tar.gz
pdf-simple-sign-67596a81532149615bae07c47f81db2e1c7f7e28.tar.xz
pdf-simple-sign-67596a81532149615bae07c47f81db2e1c7f7e28.zip
extfs-pdf: improve the listing format
Diffstat (limited to 'cmd')
-rw-r--r--cmd/extfs-pdf/main.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/cmd/extfs-pdf/main.go b/cmd/extfs-pdf/main.go
index 74f8433..e368df1 100644
--- a/cmd/extfs-pdf/main.go
+++ b/cmd/extfs-pdf/main.go
@@ -21,6 +21,7 @@ import (
"flag"
"fmt"
"os"
+ "time"
"janouch.name/pdf-simple-sign/pdf"
)
@@ -52,7 +53,8 @@ func streamSuffix(o *pdf.Object) string {
return "stream"
}
-func list(updater *pdf.Updater) {
+func list(mtime time.Time, updater *pdf.Updater) {
+ stamp := mtime.Local().Format("01-02-2006 15:04:05")
for _, o := range updater.ListIndirect() {
object, err := updater.Get(o.N, o.Generation)
size := 0
@@ -62,11 +64,11 @@ func list(updater *pdf.Updater) {
// Accidental transformation, retrieving original data is more work.
size = len(object.Serialize())
}
- fmt.Printf("-r--r--r-- 1 0 0 %d 01-01-1970 00:00 %d-%d\n",
- size, o.N, o.Generation)
+ fmt.Printf("-r--r--r-- 1 0 0 %d %s n%dg%d\n",
+ size, stamp, o.N, o.Generation)
if object.Kind == pdf.Stream {
- fmt.Printf("-r--r--r-- 1 0 0 %d 01-01-1970 00:00 %d-%d.%s\n",
- len(object.Stream), o.N, o.Generation, streamSuffix(&object))
+ fmt.Printf("-r--r--r-- 1 0 0 %d %s n%dg%d.%s\n", len(object.Stream),
+ stamp, o.N, o.Generation, streamSuffix(&object))
}
}
}
@@ -76,7 +78,7 @@ func copyout(updater *pdf.Updater, storedFilename, extractTo string) {
n, generation uint
suffix string
)
- m, err := fmt.Sscanf(storedFilename, "%d-%d%s", &n, &generation, &suffix)
+ m, err := fmt.Sscanf(storedFilename, "n%dg%d%s", &n, &generation, &suffix)
if m < 2 {
die(3, "%s: %s", storedFilename, err)
}
@@ -108,6 +110,11 @@ func main() {
die(1, "%s", err)
}
+ mtime := time.UnixMilli(0)
+ if info, err := os.Stat(documentPath); err == nil {
+ mtime = info.ModTime()
+ }
+
updater, err := pdf.NewUpdater(doc)
if err != nil {
die(2, "%s", err)
@@ -120,7 +127,7 @@ func main() {
if flag.NArg() != 2 {
usage()
} else {
- list(updater)
+ list(mtime, updater)
}
case "copyout":
if flag.NArg() != 4 {