diff --git a/Makefile b/Makefile index 9e09dc9..5a664e3 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ Mnemosyne: $(OBJ) # Files and Dependances src/funcs.o: src/funcs.h src/funcs.c -src/main.o: src/main.c src/scan.h src/window.h +src/main.o: src/main.c src/scan.h src/window.h src/funcs.h src/scan.o: src/scan.h src/scan.c src/funcs.h diff --git a/aminet.readme b/aminet.readme index 60afe4b..6c65313 100644 --- a/aminet.readme +++ b/aminet.readme @@ -2,7 +2,7 @@ Short: Disk usage statistics+file/folder utility Uploader: arisamiga@gmail.com (Aris Sokianos) Author: Aris (arisamiga) Sokianos Type: util/misc -Version: 1.1.1 +Version: 1.2.0 Architecture: m68k-amigaos >= 3.0.0 Distribution: Aminet Replaces: util/misc/Mnemosyne.lha diff --git a/build/Guide_Images/Tooltypes.iff b/build/Guide_Images/Tooltypes.iff new file mode 100644 index 0000000..0bd3b7a Binary files /dev/null and b/build/Guide_Images/Tooltypes.iff differ diff --git a/build/Guide_Images/mnemosyne.iff b/build/Guide_Images/mnemosyne.iff index 8edd98f..c5fd531 100644 Binary files a/build/Guide_Images/mnemosyne.iff and b/build/Guide_Images/mnemosyne.iff differ diff --git a/build/Guide_Images/mnemosyne_back.iff b/build/Guide_Images/mnemosyne_back.iff index 408d878..2953cc6 100644 Binary files a/build/Guide_Images/mnemosyne_back.iff and b/build/Guide_Images/mnemosyne_back.iff differ diff --git a/build/Guide_Images/mnemosyne_folder_ready.iff b/build/Guide_Images/mnemosyne_folder_ready.iff index 6f950cf..5e8b1af 100644 Binary files a/build/Guide_Images/mnemosyne_folder_ready.iff and b/build/Guide_Images/mnemosyne_folder_ready.iff differ diff --git a/build/Guide_Images/mnemosyne_ready.iff b/build/Guide_Images/mnemosyne_ready.iff index 4b61fdc..27f27f9 100644 Binary files a/build/Guide_Images/mnemosyne_ready.iff and b/build/Guide_Images/mnemosyne_ready.iff differ diff --git a/build/Guide_Images/mnemosyne_result.iff b/build/Guide_Images/mnemosyne_result.iff index 8284cec..85eaa58 100644 Binary files a/build/Guide_Images/mnemosyne_result.iff and b/build/Guide_Images/mnemosyne_result.iff differ diff --git a/build/Guide_Images/mnemosyne_scanning.iff b/build/Guide_Images/mnemosyne_scanning.iff index d555f18..ae5391c 100644 Binary files a/build/Guide_Images/mnemosyne_scanning.iff and b/build/Guide_Images/mnemosyne_scanning.iff differ diff --git a/build/Guide_Images/pressdrawer.iff b/build/Guide_Images/pressdrawer.iff index 6b190d9..4e2dacd 100644 Binary files a/build/Guide_Images/pressdrawer.iff and b/build/Guide_Images/pressdrawer.iff differ diff --git a/build/Mnemosyne.guide b/build/Mnemosyne.guide index 61b2ef7..08dced3 100644 --- a/build/Mnemosyne.guide +++ b/build/Mnemosyne.guide @@ -1,7 +1,7 @@ @database Mnemosyne.guide @author "Aris (Arisamiga) Sokianos" -@$VER: Mnemosyne.Guide 1.1.1 +@$VER: Mnemosyne.Guide 1.2.0 @(c) 2023 Aris (Arisamiga) Sokianos @Node "Main" "Mnemosyne" @@ -15,7 +15,7 @@ |_| |_|_| |_|\\___|_| |_| |_|\\___/|___/\\___ |_| |_|\\___| |___/ -@{jright}Version 1.1.1 +@{jright}Version 1.2.0 @{jcenter} @@ -29,6 +29,7 @@ which can be used to see how much disk space your files and folders are taking u @{" Requirements " Link "Requirements"} @{" Installation " Link "Installation"} @{" Usage " Link "Usage"} + @{" Tooltypes " Link "Tooltypes"} @{" Notes " Link "Notes"} @EndNode @@ -231,11 +232,62 @@ There are 2 ways to use Mnemosyne: + Quit: Quits Mnemosyne. +@EndNode + +@Node "Tooltypes" "Tooltypes" +@Next "Notes" +@Prev "Usage" +@Toc "Main" + +@{jleft}@{lindent 3} +@{b}Tooltypes@{ub} +*************** + +Mnemosyne has available tooltypes already in the .info file. + +These tooltypes can be used to change the behavior of Mnemosyne +to use or not use certain features. + + How to use Tooltypes: + --------------------- + + To use tooltypes, + you need to @{b}open the Mnemosyne icon + information window@{ub} and click on the @{b}"Icon"@{ub} tab. + + There you will see a list of tooltypes that you can use. + + There will be mostly words with @{b}()@{ub} around them + which means that the specific feature is @{b}disabled@{ub}. + To enable it, just remove the @{b}()@{ub}. + + Using the Tooltypes on the Menu Bar: + ------------------------------------ + You can also change the features you want by + using Mnemosyne's Menu Bar. + They will be under @{b}Settings@{ub} on menu. + @{lindent 8}@{IMG "GUIDEDIR:Guide_Images/Tooltypes.iff"}@{lindent 0} + The features that are @{b}enabled@{ub} will have a @{b}*@{ub} next to them. + + Note: The Settings Names are @{b}not the same as the tooltypes names@{ub}. + (If you want to know the tooltype name try to enable the feature + and then open the icon information window and see the tooltype name) + + + + The available tooltypes are: + ---------------------------- + + + @{b}NOROUND@{ub} - This will disable the rounding of certain size values + (Mainly the overall size of a folder). + + + @EndNode @Node "Notes" "Notes" -@Prev "Usage" +@Prev "Tooltypes" @Toc "Main" @{jleft}@{lindent 3} @@ -256,4 +308,8 @@ as some files and folders have a very small contribution to the total size of the directory and having them rounded up will cause the total to be more than 100%. +- The rounding of the overall size of a folder is done +by rounding a number DOWN to the nearest integer so for example +19.9MB will be rounded to 19MB. + @EndNode \ No newline at end of file diff --git a/build/Mnemosyne.info b/build/Mnemosyne.info index 8fac3a5..dfaab23 100644 Binary files a/build/Mnemosyne.info and b/build/Mnemosyne.info differ diff --git a/images/Tooltypes.PNG b/images/Tooltypes.PNG new file mode 100644 index 0000000..b7ac691 Binary files /dev/null and b/images/Tooltypes.PNG differ diff --git a/images/mnemosyne.png b/images/mnemosyne.png index f3575b7..0575cf5 100644 Binary files a/images/mnemosyne.png and b/images/mnemosyne.png differ diff --git a/images/mnemosyneG.png b/images/mnemosyneG.png index 881f0e2..603478b 100644 Binary files a/images/mnemosyneG.png and b/images/mnemosyneG.png differ diff --git a/images/mnemosyne_Gresult.png b/images/mnemosyne_Gresult.png index fc9e222..7ccc4ba 100644 Binary files a/images/mnemosyne_Gresult.png and b/images/mnemosyne_Gresult.png differ diff --git a/images/mnemosyne_back.png b/images/mnemosyne_back.png index ebb504b..aa01897 100644 Binary files a/images/mnemosyne_back.png and b/images/mnemosyne_back.png differ diff --git a/images/mnemosyne_folder_ready.png b/images/mnemosyne_folder_ready.png index 392f68c..e924985 100644 Binary files a/images/mnemosyne_folder_ready.png and b/images/mnemosyne_folder_ready.png differ diff --git a/images/mnemosyne_ready.png b/images/mnemosyne_ready.png index 9293fd3..e9feb66 100644 Binary files a/images/mnemosyne_ready.png and b/images/mnemosyne_ready.png differ diff --git a/images/mnemosyne_result.png b/images/mnemosyne_result.png index bc173e6..c666394 100644 Binary files a/images/mnemosyne_result.png and b/images/mnemosyne_result.png differ diff --git a/images/mnemosyne_scanning.png b/images/mnemosyne_scanning.png index 23ece6d..74c4f01 100644 Binary files a/images/mnemosyne_scanning.png and b/images/mnemosyne_scanning.png differ diff --git a/images/pressdrawer.png b/images/pressdrawer.png index 3627d64..c89774e 100644 Binary files a/images/pressdrawer.png and b/images/pressdrawer.png differ diff --git a/src/funcs.c b/src/funcs.c index ffd805f..39682f0 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -8,11 +8,16 @@ #include #include #include +#include + +#include #include #include "funcs.h" +BOOL NoRoundOption = FALSE; + int returnFormatValue(STRPTR format){ if(strcmp(format, "B") == 0) { @@ -235,3 +240,104 @@ size_t safeStrlen(const char *str) } return len; } + +// Get path from where the program is running + +char* getProgramPath() { + char* path = AllocVec(sizeof(char) * 256, MEMF_CLEAR); + if (path == NULL) { + // Handle error + return NULL; + } + + BPTR lock = Lock("", ACCESS_READ); + if (lock) + { + NameFromLock(lock, path, 256); + // Append Mnemosyne to the path + strcat(path, "Mnemosyne"); + UnLock(lock); + } + return path; +} + +void initializeIconTooltypes(void) +{ + + // Get path from where the program is running + char* path = getProgramPath(); + + if (IconBase) + { + struct DiskObject *diskObj = GetDiskObjectNew(path); + if(diskObj) + { + // Check if the tooltypes are empty + if (diskObj->do_ToolTypes == NULL) + { + // printf("Empty\n"); + NoRoundOption = FALSE; + FreeDiskObject(diskObj); + return; + } + + char *buf = AllocVec(sizeof(char) * 256, MEMF_CLEAR); + + for (STRPTR *tool_types = diskObj->do_ToolTypes; (buf = *tool_types); ++tool_types) + { + // printf("%s\n", buf); + if (strncmp(buf, "NOROUND", 7) == 0) + { + NoRoundOption = TRUE; + } + } + // printf("%s\n", result); + FreeVec(buf); + FreeDiskObject(diskObj); + } + } +} + +void updateIconTooltypes (void) +{ + // Get path from where the program is running + char* path = getProgramPath(); + + if (IconBase) + { + struct DiskObject *diskObj = GetIconTags(path, TAG_DONE); + if(diskObj) + { + // Create array with the new tooltypes + char **newToolTypes = AllocVec(sizeof(char *) * 2, MEMF_CLEAR); + if (newToolTypes) + { + if (NoRoundOption) + { + newToolTypes[0] = "NOROUND"; + } + else + { + newToolTypes[0] = "(NOROUND)"; + } + newToolTypes[1] = NULL; + + diskObj->do_ToolTypes = (STRPTR *)newToolTypes; + + LONG errorCode; + BOOL success; + success = PutIconTags(path, diskObj, + ICONPUTA_DropNewIconToolTypes, TRUE, + ICONA_ErrorCode, &errorCode, + TAG_DONE); + + if(success == FALSE) + { + printf("Error: %ld\n", errorCode); + } + + FreeVec(newToolTypes); + } + } + } +} diff --git a/src/funcs.h b/src/funcs.h index d4b86a2..6e1f7d5 100644 --- a/src/funcs.h +++ b/src/funcs.h @@ -13,4 +13,10 @@ char* getLastTwoChars(const char*); size_t strlcpy(char *dest, const char *source, size_t size); char *string_to_lower(const char *, size_t); size_t safeStrlen(const char *str); +void initializeIconTooltypes(void); +void updateIconTooltypes (void); +// ------------ Varibles ------------ + +extern BOOL NoRoundOption; + #endif diff --git a/src/main.c b/src/main.c index e1cc9b1..aba2f20 100644 --- a/src/main.c +++ b/src/main.c @@ -3,10 +3,11 @@ #include #include "scan.h" +#include "funcs.h" #include "window.h" // Mnemosyne Version -char *vers = "\0$VER: Mnemosyne 1.1.1"; +char *vers = "\0$VER: Mnemosyne 1.2.0"; struct IntuitionBase *IntuitionBase; struct Library *UtilityBase; @@ -17,6 +18,7 @@ struct Library *ButtonBase; struct Library *GetFileBase; struct Library *GadToolsBase; struct Library *WorkbenchBase; +struct Library *IconBase; // Declare functions after main void info(void); @@ -62,11 +64,6 @@ BOOL openLibraries(void) printf( "Failed to open gadtools.library! Make sure the version is above v39.\n"); return FALSE; } - if ((WorkbenchBase = OpenLibrary("workbench.library", 39)) == NULL) { - printf( "Failed to open workbench.library! Make sure the version is above v39.\n"); - return FALSE; - } - return TRUE; } @@ -92,9 +89,32 @@ void closeLibraries(void) CloseLibrary(WorkbenchBase); } +BOOL openToolTypeLibraries(void) +{ + if ((WorkbenchBase = OpenLibrary("workbench.library", 39)) == NULL) { + printf( "Failed to open workbench.library! Make sure the version is above v39.\n"); + return FALSE; + } + if ((IconBase = OpenLibrary("icon.library", 39)) == NULL) { + printf( "Failed to open icon.library! Make sure the version is above v39.\n"); + return FALSE; + } + return TRUE; +} + + int main(int argc, char **argv) { + if (argc > 1 && argv[1][0] == '?' && !argv[1][1]) + { + info(); + return 0; + } + + if (openToolTypeLibraries()){ + initializeIconTooltypes(); + } if (argc <= 1) { if (openLibraries()) @@ -122,6 +142,7 @@ int main(int argc, char **argv) printf("Scanning: %s\n\n", argv[1]); printf("| Name: \t\t Size: \n\n"); scanPath(argv[1], FALSE, FALSE); + closeLibraries(); return 0; } diff --git a/src/scan.c b/src/scan.c index 80b4ff1..5701d86 100644 --- a/src/scan.c +++ b/src/scan.c @@ -49,12 +49,6 @@ STRPTR returnGivenFormat(int format) { } } -STRPTR returnFormatWithTotal(void){ - STRPTR buffer = AllocVec(64, MEMF_CLEAR); - snprintf(buffer, 64, " (%lu %s)", totalSize, returnGivenFormat(currentFormat)); - return buffer; -} - int correctFormat(ULONG size){ if (size / 1024 / 1024 / 1024 / 1024 > 0) return 4; @@ -92,6 +86,20 @@ ULONG devideByGivenFormat(ULONG size, int format){ } } + + +STRPTR returnFormatWithTotal(void){ + STRPTR buffer = AllocVec(64, MEMF_CLEAR); + if (NoRoundOption == TRUE){ + snprintf(buffer, 64, " (%lu %s)", totalSize, returnGivenFormat(currentFormat)); + } else { + int format = correctFormat(totalSize); + snprintf(buffer, 64, " (%lu %s)", devideByGivenFormat(totalSize, format), returnGivenFormat(format)); + } + + return buffer; +} + void addToTotalSize(ULONG size) { if (totalSize + size < totalSize) @@ -223,7 +231,12 @@ void scanPath(char *path, BOOL subFoldering, struct Gadget *listGadget) if (!subFoldering && !listGadget) { strcat(fib->fib_FileName, "/"); - printf("| %-20s: %12lu %s\n", fib->fib_FileName, totalSize - oldTotalSize, returnGivenFormat(currentFormat)); + if (NoRoundOption == FALSE) { + int format = correctFormat(totalSize - oldTotalSize); + printf("| %-20s: %12lu %s\n", fib->fib_FileName, devideByGivenFormat(totalSize - oldTotalSize, format), returnGivenFormat(format)); + } else { + printf("| %-20s: %12lu %s\n", fib->fib_FileName, totalSize - oldTotalSize, returnGivenFormat(currentFormat)); + } } if (listGadget) { @@ -234,7 +247,7 @@ void scanPath(char *path, BOOL subFoldering, struct Gadget *listGadget) oldTotalSize = devideByGivenFormat(oldTotalSize, currentFormat); } // printf("Total: %ld - %ld = %ld\n", totalSize, oldTotalSize, totalSize - oldTotalSize); - if((long)(totalSize - oldTotalSize) < 0 || currentFormat == 0){ + if((long)(totalSize - oldTotalSize) < 0 || currentFormat == 0 || NoRoundOption == FALSE){ int format = correctFormat(totalSize - oldTotalSize); addToList(fib->fib_FileName, devideByGivenFormat(totalSize - oldTotalSize, format), returnGivenFormat(format)); } else { @@ -299,7 +312,12 @@ void scanPath(char *path, BOOL subFoldering, struct Gadget *listGadget) } if (!subFoldering && !listGadget) { - printf("\n--> Total Size Of Path Given: %lu %s\n\n", totalSize, returnGivenFormat(currentFormat)); + if (NoRoundOption == FALSE) { + int format = correctFormat(totalSize); + printf("\n--> Total Size Of Path Given: %lu %s\n\n", devideByGivenFormat(totalSize, format), returnGivenFormat(format)); + } else { + printf("\n--> Total Size Of Path Given: %lu %s\n\n", totalSize, returnGivenFormat(currentFormat)); + } } FreeVec(fib); UnLock(lockPath); diff --git a/src/window.c b/src/window.c index e4d11cb..9e3cfa7 100644 --- a/src/window.c +++ b/src/window.c @@ -65,6 +65,7 @@ enum OID_MENU_OPEN_DIR, OID_MENU_ABOUT, OID_MENU_QUIT, + OID_MENU_NO_ROUND, OID_SCAN_BUTTON, OID_SCAN_OPEN, OID_GIVEN_PATH, @@ -80,6 +81,9 @@ static struct NewMenu MenuArray[] = { {NM_ITEM, NM_BARLABEL,0,0,0,0 }, {NM_ITEM, "About...", 0, 0, 0, (APTR)OID_MENU_ABOUT}, {NM_ITEM, "Quit...", 0, 0, 0, (APTR)OID_MENU_QUIT}, + {NM_TITLE, "Settings", 0, 0, 0, 0}, + {NM_ITEM, "Round Numbers", 0, CHECKIT, 0, (APTR)OID_MENU_NO_ROUND}, + {NM_END, NULL, 0, 0, 0, NULL} }; @@ -119,6 +123,15 @@ static int __SAVE_DS__ __ASM__ myCompare2(__REG__(a0, struct Hook *hook), __REG_ } +void UpdateMenuToolTypes() { + if (NoRoundOption) { + MenuArray[7] = (struct NewMenu){NM_ITEM, "Round Numbers", 0, CHECKIT, 0, (APTR)OID_MENU_NO_ROUND}; + } + else { + MenuArray[7] = (struct NewMenu){NM_ITEM, "Round Numbers", 0, CHECKIT|CHECKED, 0, (APTR)OID_MENU_NO_ROUND}; + } +} + void UpdateMenu(struct Window *intuiwin, BOOL enabled){ APTR *visualInfo; @@ -216,6 +229,7 @@ void updateMenuItems(struct Window *intuiwin, BOOL enabled){ else { MenuArray[2] = (struct NewMenu){NM_ITEM, "Open in Workbench...", 0, ITEMENABLED, 0, (APTR)OID_MENU_OPEN_DIR}; } + UpdateMenuToolTypes(); // SetAttrs(windowObject, WINDOW_NewMenu, MenuArray, TAG_DONE); UpdateMenu(intuiwin, FALSE); } @@ -422,6 +436,8 @@ void createWindow(char *Path) {60, "Size", 0}, { -1, (STRPTR)~0, -1 } }; + UpdateMenuToolTypes(); + listBrowser = (struct Gadget *)ListBrowserObject, GA_ID, OID_MAIN_LIST, GA_RelVerify, TRUE, @@ -498,7 +514,7 @@ void createWindow(char *Path) WINDOW_Icon, GetDiskObject("PROGDIR:Mnemosyne"), WINDOW_AppPort, appPort, WA_Activate, TRUE, - WA_Title, "Mnemosyne 1.1.1", + WA_Title, "Mnemosyne 1.2.0", WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_DepthGadget, TRUE, @@ -620,6 +636,14 @@ void processEvents(Object *windowObject, // printf("About window closed\n"); toggleBusyPointer(windowObject, FALSE); break; + case OID_MENU_NO_ROUND: + { + NoRoundOption = !NoRoundOption; + UpdateMenuToolTypes(); + updateIconTooltypes(); + UpdateMenu(intuiwin, TRUE); + break; + } case OID_MENU_QUIT: end = TRUE; break;