mirror of
https://github.com/Hopiu/micro.git
synced 2026-05-21 21:01:53 +00:00
save: Convert os.IsNotExist() into errors.Is()
This commit is contained in:
parent
3fcaf16074
commit
edc5ff75e3
1 changed files with 2 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue