2024-12-10 15:54:22 +01:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2024-12-11 15:59:55 +01:00
|
|
|
func CreateFile(ctx context.Context, filePath string) (io.ReadWriter, error) {
|
|
|
|
rwFile, err := os.Create(filePath)
|
2024-12-10 15:54:22 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-12-11 15:59:55 +01:00
|
|
|
|
|
|
|
return rwFile, nil
|
2024-12-10 15:54:22 +01:00
|
|
|
}
|
|
|
|
|
2024-12-11 15:59:55 +01:00
|
|
|
func OpenFile(ctx context.Context, filePath string) (io.ReadWriter, error) {
|
|
|
|
file, err := os.OpenFile(filePath, os.O_RDWR, 0644)
|
2024-12-10 15:54:22 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return file, nil
|
|
|
|
}
|