mirror of
https://github.com/Picocrypt/Picocrypt.git
synced 2025-05-13 14:08:31 +02:00
Compare commits
7 commits
504e908195
...
c21e99357a
Author | SHA1 | Date | |
---|---|---|---|
|
c21e99357a | ||
|
df5ef8e9ee | ||
|
6140e2beb6 | ||
|
7a1d105a43 | ||
|
99a04de263 | ||
|
ee2abd053c | ||
|
75c0a017f9 |
2 changed files with 33 additions and 29 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -20,3 +20,5 @@
|
|||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
TODO
|
||||
|
|
|
@ -651,13 +651,13 @@ func draw() {
|
|||
|
||||
giu.Row(
|
||||
giu.Checkbox("Deniability", &deniability),
|
||||
giu.Tooltip("Add plausible deniability to the volume\nIf enabled, comments will not be usable"),
|
||||
giu.Tooltip("Warning: only use this if you know what it does!"),
|
||||
giu.Dummy(-170, 0),
|
||||
giu.Style().SetDisabled(!(len(allFiles) > 1 || len(onlyFolders) > 0)).To(
|
||||
giu.Checkbox("Recursively", &recursively).OnChange(func() {
|
||||
compress = false
|
||||
}),
|
||||
giu.Tooltip("Encrypt and decrypt recursive files individually"),
|
||||
giu.Tooltip("Warning: only use this if you know what it does!"),
|
||||
),
|
||||
).Build()
|
||||
|
||||
|
@ -690,7 +690,7 @@ func draw() {
|
|||
sameLevel = false
|
||||
}
|
||||
}),
|
||||
giu.Tooltip("Extract .zip upon decryption (may overwrite)"),
|
||||
giu.Tooltip("Extract .zip upon decryption (may overwrite files)"),
|
||||
),
|
||||
giu.Dummy(-170, 0),
|
||||
giu.Style().SetDisabled(!autoUnzip).To(
|
||||
|
@ -790,8 +790,24 @@ func draw() {
|
|||
return
|
||||
}
|
||||
if requiredFreeSpace > 0 {
|
||||
multiplier := 1
|
||||
if len(allFiles) > 1 || len(onlyFolders) > 0 { // need a temporary zip file
|
||||
multiplier++
|
||||
}
|
||||
if deniability {
|
||||
multiplier++
|
||||
}
|
||||
if split {
|
||||
multiplier++
|
||||
}
|
||||
if recombine {
|
||||
multiplier++
|
||||
}
|
||||
if autoUnzip {
|
||||
multiplier++
|
||||
}
|
||||
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
||||
giu.Label("Ready (ensure " + sizeify(requiredFreeSpace) + " of disk space is free)"),
|
||||
giu.Label("Ready (ensure >" + sizeify(requiredFreeSpace*int64(multiplier)) + " of disk space is free)"),
|
||||
).Build()
|
||||
} else {
|
||||
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
||||
|
@ -858,7 +874,12 @@ func onDrop(names []string) {
|
|||
|
||||
// One item dropped
|
||||
if len(names) == 1 {
|
||||
stat, _ := os.Stat(names[0])
|
||||
stat, err := os.Stat(names[0])
|
||||
if err != nil {
|
||||
mainStatus = "Failed to stat dropped item"
|
||||
mainStatusColor = RED
|
||||
return
|
||||
}
|
||||
|
||||
// A folder was dropped
|
||||
if stat.IsDir() {
|
||||
|
@ -869,14 +890,9 @@ func onDrop(names []string) {
|
|||
onlyFolders = append(onlyFolders, names[0])
|
||||
inputFile = filepath.Join(filepath.Dir(names[0]), "encrypted-"+strconv.Itoa(int(time.Now().Unix()))) + ".zip"
|
||||
outputFile = inputFile + ".pcv"
|
||||
size, err := dirSize(names[0])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
requiredFreeSpace = 2 * size
|
||||
} else { // A file was dropped
|
||||
files++
|
||||
requiredFreeSpace += stat.Size()
|
||||
requiredFreeSpace = stat.Size()
|
||||
|
||||
// Is the file a part of a split volume?
|
||||
nums := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
|
||||
|
@ -913,8 +929,8 @@ func onDrop(names []string) {
|
|||
}
|
||||
totalFiles++
|
||||
compressTotal += stat.Size()
|
||||
requiredFreeSpace += stat.Size()
|
||||
}
|
||||
requiredFreeSpace = compressTotal
|
||||
} else {
|
||||
outputFile = names[0][:len(names[0])-4]
|
||||
}
|
||||
|
@ -1017,7 +1033,7 @@ func onDrop(names []string) {
|
|||
allFiles = append(allFiles, name)
|
||||
|
||||
compressTotal += stat.Size()
|
||||
requiredFreeSpace += 2 * stat.Size()
|
||||
requiredFreeSpace += stat.Size()
|
||||
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
||||
giu.Update()
|
||||
}
|
||||
|
@ -1056,7 +1072,7 @@ func onDrop(names []string) {
|
|||
if err == nil && !stat.IsDir() {
|
||||
allFiles = append(allFiles, path)
|
||||
compressTotal += stat.Size()
|
||||
requiredFreeSpace += 2 * stat.Size()
|
||||
requiredFreeSpace += stat.Size()
|
||||
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
||||
giu.Update()
|
||||
}
|
||||
|
@ -1101,7 +1117,7 @@ func work() {
|
|||
}()
|
||||
|
||||
// Combine/compress all files into a .zip file if needed
|
||||
if len(allFiles) > 1 || len(onlyFolders) > 0 || compress {
|
||||
if len(allFiles) > 1 || len(onlyFolders) > 0 {
|
||||
// Consider case where compressing only one file
|
||||
files := allFiles
|
||||
if len(allFiles) == 0 {
|
||||
|
@ -2553,20 +2569,6 @@ func unpackArchive(zipPath string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func dirSize(path string) (int64, error) {
|
||||
var size int64
|
||||
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
size += info.Size()
|
||||
}
|
||||
return err
|
||||
})
|
||||
return size, err
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Create the main window
|
||||
window = giu.NewMasterWindow("Picocrypt "+version[1:], 318, 507, giu.MasterWindowFlagsNotResizable)
|
||||
|
|
Loading…
Add table
Reference in a new issue