-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add live drive regeneration and loading (#122)
- Loading branch information
Showing
7 changed files
with
106 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright Terence J. Boldt (c)2023 | ||
// Use of this source code is governed by an MIT | ||
// license that can be found in the LICENSE file. | ||
|
||
// This file is used for handling ProDOS image generation | ||
|
||
package drive | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/tjboldt/ProDOS-Utilities/prodos" | ||
) | ||
|
||
// GetDriveImageDirectory gets the default directory for driveimage | ||
func GetDriveImageDirectory() (string, error) { | ||
exec, err := os.Executable() | ||
if err != nil { | ||
fmt.Printf("ERROR: %s", err.Error()) | ||
return "", err | ||
} | ||
driveImageDirectory := filepath.Join(filepath.Dir(filepath.Dir(exec)), "driveimage") | ||
|
||
return driveImageDirectory, nil | ||
} | ||
|
||
// GenerateDriveFromDirectory regenerates a ProDOS drive from a host directory | ||
func GenerateDriveFromDirectory(volumeName string, directory string) (prodos.ReaderWriterAt, error) { | ||
drive := prodos.NewMemoryFile(0x2000000) | ||
fmt.Printf("Generating Drive in memory from: %s\n", directory) | ||
prodos.CreateVolume(drive, volumeName, 65535) | ||
err := prodos.AddFilesFromHostDirectory(drive, directory, "/"+volumeName+"/", true) | ||
return drive, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters