mirror of
https://github.com/Picocrypt/Picocrypt.git
synced 2025-05-13 06:08:30 +02:00
Compare commits
6 commits
9b2b69e442
...
df5ef8e9ee
Author | SHA1 | Date | |
---|---|---|---|
|
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 workspace file
|
||||||
go.work
|
go.work
|
||||||
go.work.sum
|
go.work.sum
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
|
@ -651,13 +651,13 @@ func draw() {
|
||||||
|
|
||||||
giu.Row(
|
giu.Row(
|
||||||
giu.Checkbox("Deniability", &deniability),
|
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.Dummy(-170, 0),
|
||||||
giu.Style().SetDisabled(!(len(allFiles) > 1 || len(onlyFolders) > 0)).To(
|
giu.Style().SetDisabled(!(len(allFiles) > 1 || len(onlyFolders) > 0)).To(
|
||||||
giu.Checkbox("Recursively", &recursively).OnChange(func() {
|
giu.Checkbox("Recursively", &recursively).OnChange(func() {
|
||||||
compress = false
|
compress = false
|
||||||
}),
|
}),
|
||||||
giu.Tooltip("Encrypt and decrypt recursive files individually"),
|
giu.Tooltip("Warning: only use this if you know what it does!"),
|
||||||
),
|
),
|
||||||
).Build()
|
).Build()
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ func draw() {
|
||||||
sameLevel = false
|
sameLevel = false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
giu.Tooltip("Extract .zip upon decryption (may overwrite)"),
|
giu.Tooltip("Extract .zip upon decryption (may overwrite files)"),
|
||||||
),
|
),
|
||||||
giu.Dummy(-170, 0),
|
giu.Dummy(-170, 0),
|
||||||
giu.Style().SetDisabled(!autoUnzip).To(
|
giu.Style().SetDisabled(!autoUnzip).To(
|
||||||
|
@ -790,8 +790,24 @@ func draw() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if requiredFreeSpace > 0 {
|
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.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()
|
).Build()
|
||||||
} else {
|
} else {
|
||||||
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
||||||
|
@ -858,7 +874,12 @@ func onDrop(names []string) {
|
||||||
|
|
||||||
// One item dropped
|
// One item dropped
|
||||||
if len(names) == 1 {
|
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
|
// A folder was dropped
|
||||||
if stat.IsDir() {
|
if stat.IsDir() {
|
||||||
|
@ -869,14 +890,9 @@ func onDrop(names []string) {
|
||||||
onlyFolders = append(onlyFolders, names[0])
|
onlyFolders = append(onlyFolders, names[0])
|
||||||
inputFile = filepath.Join(filepath.Dir(names[0]), "encrypted-"+strconv.Itoa(int(time.Now().Unix()))) + ".zip"
|
inputFile = filepath.Join(filepath.Dir(names[0]), "encrypted-"+strconv.Itoa(int(time.Now().Unix()))) + ".zip"
|
||||||
outputFile = inputFile + ".pcv"
|
outputFile = inputFile + ".pcv"
|
||||||
size, err := dirSize(names[0])
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
requiredFreeSpace = 2 * size
|
|
||||||
} else { // A file was dropped
|
} else { // A file was dropped
|
||||||
files++
|
files++
|
||||||
requiredFreeSpace += stat.Size()
|
requiredFreeSpace = stat.Size()
|
||||||
|
|
||||||
// Is the file a part of a split volume?
|
// Is the file a part of a split volume?
|
||||||
nums := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
|
nums := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
|
||||||
|
@ -913,8 +929,8 @@ func onDrop(names []string) {
|
||||||
}
|
}
|
||||||
totalFiles++
|
totalFiles++
|
||||||
compressTotal += stat.Size()
|
compressTotal += stat.Size()
|
||||||
requiredFreeSpace += stat.Size()
|
|
||||||
}
|
}
|
||||||
|
requiredFreeSpace = compressTotal
|
||||||
} else {
|
} else {
|
||||||
outputFile = names[0][:len(names[0])-4]
|
outputFile = names[0][:len(names[0])-4]
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1033,7 @@ func onDrop(names []string) {
|
||||||
allFiles = append(allFiles, name)
|
allFiles = append(allFiles, name)
|
||||||
|
|
||||||
compressTotal += stat.Size()
|
compressTotal += stat.Size()
|
||||||
requiredFreeSpace += 2 * stat.Size()
|
requiredFreeSpace += stat.Size()
|
||||||
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
||||||
giu.Update()
|
giu.Update()
|
||||||
}
|
}
|
||||||
|
@ -1056,7 +1072,7 @@ func onDrop(names []string) {
|
||||||
if err == nil && !stat.IsDir() {
|
if err == nil && !stat.IsDir() {
|
||||||
allFiles = append(allFiles, path)
|
allFiles = append(allFiles, path)
|
||||||
compressTotal += stat.Size()
|
compressTotal += stat.Size()
|
||||||
requiredFreeSpace += 2 * stat.Size()
|
requiredFreeSpace += stat.Size()
|
||||||
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
||||||
giu.Update()
|
giu.Update()
|
||||||
}
|
}
|
||||||
|
@ -1101,7 +1117,7 @@ func work() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Combine/compress all files into a .zip file if needed
|
// 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
|
// Consider case where compressing only one file
|
||||||
files := allFiles
|
files := allFiles
|
||||||
if len(allFiles) == 0 {
|
if len(allFiles) == 0 {
|
||||||
|
@ -2553,20 +2569,6 @@ func unpackArchive(zipPath string) error {
|
||||||
return nil
|
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() {
|
func main() {
|
||||||
// Create the main window
|
// Create the main window
|
||||||
window = giu.NewMasterWindow("Picocrypt "+version[1:], 318, 507, giu.MasterWindowFlagsNotResizable)
|
window = giu.NewMasterWindow("Picocrypt "+version[1:], 318, 507, giu.MasterWindowFlagsNotResizable)
|
||||||
|
|
Loading…
Add table
Reference in a new issue