Version v0.3.46 - -m Fix directory decryption default filename - remove .tar.gz.otp extension

This commit is contained in:
2025-12-27 12:10:14 -05:00
parent 7c2821dd0d
commit 974470238d
3 changed files with 24 additions and 22 deletions

View File

@@ -58,14 +58,14 @@ One-time pads can be trivially encrypted and decrypted using pencil and paper, m
### Download Pre-Built Binaries
**[Download Current Linux x86](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.44/otp-v0.3.44-linux-x86_64)**
**[Download Current Linux x86](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.45/otp-v0.3.45-linux-x86_64)**
**[Download Current Raspberry Pi 64](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.44/otp-v0.3.44-linux-arm64)**
**[Download Current Raspberry Pi 64](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.45/otp-v0.3.45-linux-arm64)**
After downloading:
```bash
# Rename for convenience, then make executable
mv otp-v0.3.44-linux-x86_64 otp
mv otp-v0.3.45-linux-x86_64 otp
chmod +x otp
# Run it

View File

@@ -23,7 +23,7 @@
#include <ctype.h>
// Version - Updated automatically by build.sh
#define OTP_VERSION "v0.3.44"
#define OTP_VERSION "v0.3.45"
// Constants
#define MAX_INPUT_SIZE 4096

View File

@@ -334,7 +334,15 @@ int handle_decrypt_menu(void) {
temp_default[sizeof(temp_default) - 1] = '\0';
// Remove common encrypted extensions to get a better default
if (strstr(temp_default, ".otp.asc")) {
if (strstr(temp_default, ".tar.gz.otp")) {
// Directory archive - remove .tar.gz.otp to get original directory name
char* ext_pos = strstr(temp_default, ".tar.gz.otp");
*ext_pos = '\0';
} else if (strstr(temp_default, ".tar.otp")) {
// Directory archive without compression - remove .tar.otp
char* ext_pos = strstr(temp_default, ".tar.otp");
*ext_pos = '\0';
} else if (strstr(temp_default, ".otp.asc")) {
// Replace .otp.asc with original extension or no extension
char* ext_pos = strstr(temp_default, ".otp.asc");
*ext_pos = '\0';
@@ -402,7 +410,15 @@ int handle_decrypt_menu(void) {
temp_default[sizeof(temp_default) - 1] = '\0';
// Remove common encrypted extensions to get a better default
if (strstr(temp_default, ".otp.asc")) {
if (strstr(temp_default, ".tar.gz.otp")) {
// Directory archive - remove .tar.gz.otp to get original directory name
char* ext_pos = strstr(temp_default, ".tar.gz.otp");
*ext_pos = '\0';
} else if (strstr(temp_default, ".tar.otp")) {
// Directory archive without compression - remove .tar.otp
char* ext_pos = strstr(temp_default, ".tar.otp");
*ext_pos = '\0';
} else if (strstr(temp_default, ".otp.asc")) {
// Replace .otp.asc with original extension or no extension
char* ext_pos = strstr(temp_default, ".otp.asc");
*ext_pos = '\0';
@@ -595,23 +611,9 @@ int handle_directory_encrypt(void) {
return 1;
}
// Generate default output filename in the same directory as the source
// Generate default output filename - append .tar.gz.otp to the directory path
char default_output[1024];
const char* dir_name = strrchr(dir_path, '/');
if (dir_name) {
// Has a path component - save in same directory
size_t parent_len = dir_name - dir_path;
char parent_dir[1024];
strncpy(parent_dir, dir_path, parent_len);
parent_dir[parent_len] = '\0';
dir_name++; // Skip the '/'
snprintf(default_output, sizeof(default_output), "%s/%s.tar.gz.otp", parent_dir, dir_name);
} else {
// No path component - save in current directory
snprintf(default_output, sizeof(default_output), "%s.tar.gz.otp", dir_path);
}
snprintf(default_output, sizeof(default_output), "%s.tar.gz.otp", dir_path);
// Get output filename
char output_file[512];