Skip to content

Commit

Permalink
open files O_RDONLY for read-only operations
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacejo authored and tjboldt committed Jan 14, 2024
1 parent 30f0b03 commit 2477b4a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {

func dumpFile(fileName string, pathName string) {
checkPathName(pathName)
file, err := os.OpenFile(fileName, os.O_RDWR, 0755)
file, err := os.OpenFile(fileName, os.O_RDONLY, 0755)
if err != nil {
fmt.Printf("Failed to open drive image %s:\n %s", fileName, err)
os.Exit(1)
Expand All @@ -94,7 +94,7 @@ func dumpFile(fileName string, pathName string) {

func dumpDirectory(fileName string, pathName string) {
checkPathName(pathName)
file, err := os.OpenFile(fileName, os.O_RDWR, 0755)
file, err := os.OpenFile(fileName, os.O_RDONLY, 0755)
if err != nil {
fmt.Printf("Failed to open drive image %s:\n %s", fileName, err)
os.Exit(1)
Expand Down Expand Up @@ -176,7 +176,7 @@ func writeBlock(blockNumber int, fileName string, inFileName string) {

func readBlock(blockNumber int, fileName string) {
fmt.Printf("Reading block 0x%04X (%d):\n\n", blockNumber, blockNumber)
file, err := os.OpenFile(fileName, os.O_RDWR, 0755)
file, err := os.OpenFile(fileName, os.O_RDONLY, 0755)
if err != nil {
fmt.Printf("Failed to open drive image %s:\n %s", fileName, err)
os.Exit(1)
Expand Down Expand Up @@ -209,7 +209,7 @@ func put(fileName string, pathName string, fileType int, auxType int, inFileName

func get(fileName string, pathName string, outFileName string) {
checkPathName(pathName)
file, err := os.OpenFile(fileName, os.O_RDWR, 0755)
file, err := os.OpenFile(fileName, os.O_RDONLY, 0755)
if err != nil {
fmt.Printf("Failed to open drive image %s:\n %s", fileName, err)
os.Exit(1)
Expand All @@ -236,7 +236,7 @@ func get(fileName string, pathName string, outFileName string) {
}

func ls(fileName string, pathName string) {
file, err := os.OpenFile(fileName, os.O_RDWR, 0755)
file, err := os.OpenFile(fileName, os.O_RDONLY, 0755)
if err != nil {
fmt.Printf("Failed to open drive image %s:\n %s", fileName, err)
os.Exit(1)
Expand Down

0 comments on commit 2477b4a

Please sign in to comment.