Files
vServer/Backend/tools/AbsPatch.go
Falknat 7a87617282 Инициализация проекта
Стабильный рабочий проект.
2025-10-02 06:02:45 +07:00

26 lines
744 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tools
import (
"fmt"
"os"
"path/filepath"
"strings"
)
// getAbsPath получает абсолютный путь с автоматической проверкой существования для файлов
func AbsPath(path string) (string, error) {
absPath, err := filepath.Abs(path)
if err != nil {
return "", fmt.Errorf("ошибка получения абсолютного пути: %v", err)
}
// Проверяем существование только для файлов (с расширением)
if strings.Contains(filepath.Base(absPath), ".") {
if _, err := os.Stat(absPath); os.IsNotExist(err) {
return "", fmt.Errorf("файл не найден: %s", absPath)
}
}
return absPath, nil
}