Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a8578d89f62b256752f10ab861e6bdca477d95d7f3a01dcb26bf2b210943dfa7
Ticket: 516d581c047786f7a51e1a574e43e8832447cc07
A tcl command to report free usable space of a partition of native file system
User & Date: anonymous on 2025-11-21 13:39:55
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    With a tcl/tk application using several SQLite databases with SQLite Tcl interface, we need to check available disk space on the partition where the database files reside as they may grow wihout limit.
    
    For example, the VACCUM db operation, (often used on our side), quoting SQLite doc at https://sqlite.org/lang_vacuum.html "works by copying the contents of the database into a temporary database file and then overwriting the original with the contents of the temporary file.... This means that when VACUUMing a database, as much as twice the size of the original database file is required in free disk space"
    
    Not sure if this measure of free space needs byte precision
    (on our side, the info is sufficiant in Megabyte unit)
    
    For now, as Tcl lacks this fuctionality, we execute from Tcl the following small java program :
    
    import java.io.File;
    import java.lang.Math;
    
    public class java_HDfreespace {
        
        public static void main(String[] args) {
            
            // Espace disque libre utilisable en octet
                
                long freeHDspace_o = new File(args[0]).getUsableSpace();        // getUsableSpace() retourne un entier long
            
            // On convertit la valeur en Mo -> division 1048576.0 (= 1024 * 1024)
                
                double freeHDspace_mo = freeHDspace_o / 1048576.0;
            
            // Retour de la valeur arrondie à 2 décimales
                
                System.out.println(Math.round(freeHDspace_mo * 100.0) / 100.0);
            
            System.exit(0);
        }
    }
    
    
    Thank you
    
    Jean-Marie
    
  5. is_private changed to: "0"
  6. login: "anonymous"
  7. priority changed to: "5 Medium"
  8. resolution changed to: "None"
  9. severity changed to: "Minor"
  10. status changed to: "Open"
  11. submitter changed to: "anonymous"
  12. subsystem changed to: "- New Builtin Commands"
  13. title changed to:
    A tcl command to report free usable space of a partition of native file system
    
  14. type changed to: "RFE"