Index: tool/spaceanal.tcl ================================================================== --- tool/spaceanal.tcl +++ tool/spaceanal.tcl @@ -28,45 +28,50 @@ } else { set file_to_analyze $arg } } if {$file_to_analyze==""} usage -if {![file exists $file_to_analyze]} { - puts stderr "No such file: $file_to_analyze" +set root_filename $file_to_analyze +regexp {^file:(//)?([^?]*)} $file_to_analyze all x1 root_filename +if {![file exists $root_filename]} { + puts stderr "No such file: $root_filename" exit 1 } -if {![file readable $file_to_analyze]} { - puts stderr "File is not readable: $file_to_analyze" +if {![file readable $root_filename]} { + puts stderr "File is not readable: $root_filename" exit 1 } -set true_file_size [file size $file_to_analyze] +set true_file_size [file size $root_filename] if {$true_file_size<512} { - puts stderr "Empty or malformed database: $file_to_analyze" + puts stderr "Empty or malformed database: $root_filename" exit 1 } # Compute the total file size assuming test_multiplexor is being used. # Assume that SQLITE_ENABLE_8_3_NAMES might be enabled # -set extension [file extension $file_to_analyze] -set pattern $file_to_analyze +set extension [file extension $root_filename] +set pattern $root_filename append pattern {[0-3][0-9][0-9]} foreach f [glob -nocomplain $pattern] { incr true_file_size [file size $f] set extension {} } if {[string length $extension]>=2 && [string length $extension]<=4} { - set pattern [file rootname $file_to_analyze] + set pattern [file rootname $root_filename] append pattern {.[0-3][0-9][0-9]} foreach f [glob -nocomplain $pattern] { incr true_file_size [file size $f] } } # Open the database # -sqlite3 db $file_to_analyze +if {[catch {sqlite3 db $file_to_analyze -uri 1} msg]} { + puts stderr "error trying to open $file_to_analyze: $msg" + exit 1 +} register_dbstat_vtab db db eval {SELECT count(*) FROM sqlite_master} set pageSize [expr {wide([db one {PRAGMA page_size}])}] @@ -482,11 +487,11 @@ WHERE NOT is_index AND name NOT LIKE 'sqlite_master'}] set user_percent [percent $user_payload $file_bytes] # Output the summary statistics calculated above. # -puts "/** Disk-Space Utilization Report For $file_to_analyze" +puts "/** Disk-Space Utilization Report For $root_filename" catch { puts "*** As of [clock format [clock seconds] -format {%Y-%b-%d %H:%M:%S}]" } puts "" statline {Page size in bytes} $pageSize