mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
save: Convert os.IsNotExist() into errors.Is()
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -164,7 +165,7 @@ func (b *Buffer) saveToFile(filename string, withSudo bool, autoSave bool) error
|
|||||||
// Get the leading path to the file | "." is returned if there's no leading path provided
|
// Get the leading path to the file | "." is returned if there's no leading path provided
|
||||||
if dirname := filepath.Dir(absFilename); dirname != "." {
|
if dirname := filepath.Dir(absFilename); dirname != "." {
|
||||||
// Check if the parent dirs don't exist
|
// Check if the parent dirs don't exist
|
||||||
if _, statErr := os.Stat(dirname); os.IsNotExist(statErr) {
|
if _, statErr := os.Stat(dirname); errors.Is(statErr, fs.ErrNotExist) {
|
||||||
// Prompt to make sure they want to create the dirs that are missing
|
// Prompt to make sure they want to create the dirs that are missing
|
||||||
if b.Settings["mkparents"].(bool) {
|
if b.Settings["mkparents"].(bool) {
|
||||||
// Create all leading dir(s) since they don't exist
|
// Create all leading dir(s) since they don't exist
|
||||||
|
|||||||
Reference in New Issue
Block a user