Skip to content

Commit a032cb3

Browse files
Add Linux support and Dockerfile for testing
1 parent 14aa1e3 commit a032cb3

4 files changed

Lines changed: 27 additions & 12 deletions

File tree

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM golang:latest
2+
3+
WORKDIR /app
4+
COPY . .
5+
RUN go build -o diskdive .
6+
7+
ENTRYPOINT ["./diskdive"]
8+
CMD ["/app"]

internal/model/drives.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ func getWindowsDrives() ([]Drive, error) {
6161
}
6262

6363
func getUnixMounts() ([]Drive, error) {
64-
// Placeholder for future Linux support
65-
// For now, just return root
66-
home, _ := os.UserHomeDir()
67-
if home == "" {
68-
home = "/"
64+
// For Linux, return root filesystem
65+
drive := Drive{
66+
Letter: "/",
67+
Path: "/",
68+
Label: runtime.GOOS,
6969
}
70-
return []Drive{
71-
{Letter: runtime.GOOS, Path: home, Label: home},
72-
}, nil
70+
drive.TotalBytes, drive.FreeBytes = GetDiskSpace("/")
71+
return []Drive{drive}, nil
7372
}

internal/model/drives_other.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
package model
44

5+
import "syscall"
6+
57
func getPlatformDrives() ([]Drive, error) {
68
return getUnixMounts()
79
}
810

9-
func getDiskSpace(path string) (total, free int64) {
10-
// Placeholder for Unix implementation
11-
return 0, 0
11+
// GetDiskSpace returns disk space information for a given path using statfs
12+
func GetDiskSpace(path string) (total, free int64) {
13+
var stat syscall.Statfs_t
14+
if err := syscall.Statfs(path, &stat); err != nil {
15+
return 0, 0
16+
}
17+
total = int64(stat.Blocks) * int64(stat.Bsize)
18+
free = int64(stat.Bavail) * int64(stat.Bsize)
19+
return total, free
1220
}

scripts/build-mac-app.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ cat > "$APP_BUNDLE/Contents/Info.plist" << PLIST
119119
<key>CFBundlePackageType</key>
120120
<string>APPL</string>
121121
<key>LSMinimumSystemVersion</key>
122-
<string>10.13</string>
122+
<string>12.0</string>
123123
<key>NSHighResolutionCapable</key>
124124
<true/>
125125
</dict>

0 commit comments

Comments
 (0)