Copy files with relative path to active workspace directory of container

This commit is contained in:
Jan-Eric Hellenberg
2021-06-08 11:52:11 +02:00
parent b32e9c2a67
commit ce2b82d43d
6 changed files with 53 additions and 47 deletions

View File

@ -66,18 +66,14 @@ type File struct {
Content []byte `json:"content"`
}
// ToAbsolute returns the absolute path of the FilePath with respect to the given basePath. If the FilePath already is absolute, basePath will be ignored.
func (f FilePath) ToAbsolute(basePath string) string {
filePathString := string(f)
if path.IsAbs(filePathString) {
return path.Clean(filePathString)
}
return path.Clean(path.Join(basePath, filePathString))
// Cleaned returns the cleaned path of the FilePath.
func (f FilePath) Cleaned() string {
return path.Clean(string(f))
}
// AbsolutePath returns the absolute path of the file. See FilePath.ToAbsolute for details.
func (f File) AbsolutePath(basePath string) string {
return f.Path.ToAbsolute(basePath)
// CleanedPath returns the cleaned path of the file.
func (f File) CleanedPath() string {
return f.Path.Cleaned()
}
// IsDirectory returns true iff the path of the File ends with a /.