wrench::FileLocation

class FileLocation

A class that encodes a file location.

Public Functions

inline bool equal(const std::shared_ptr<FileLocation> &other)

Method to compare a file location with another.

Parameters:

other – a file location

Returns:

true if both locations are equivalent (always returns false if at least one location is SCRATCH)

std::shared_ptr<DataFile> getFile()

Get the location’s file.

Returns:

a file

std::string getPath()

Get the location’s path.

Returns:

a path

std::shared_ptr<StorageService> getStorageService()

Get the location’s storage service.

Returns:

a storage service

bool isScratch() const

Get the location’s scratch-ness.

Returns:

true if the location is SCRATCH

std::shared_ptr<StorageService> setStorageService(std::shared_ptr<StorageService> &storage_service)

Set location’s storage service.

Parameters:

storage_service – the storage service

Returns:

The updated storage service

std::string toString()

Give a <ss1 name>:<mount point>:<dir>” string for the location.

Returns:

A string

Public Static Functions

static inline bool equal(const std::shared_ptr<FileLocation> &lhs, const std::shared_ptr<FileLocation> &rhs)

Method to compare two file locations.

Parameters:
  • lhs – a file location

  • rhs – a file location

Returns:

true if both locations are equivalent (always returns false if at least one location is SCRATCH)

static std::shared_ptr<FileLocation> LOCATION(const std::shared_ptr<StorageService> &ss, const std::shared_ptr<DataFile> &file)

Static location that denotes a compute service’s scratch space.

File location specifier for a storage service’s (single) mount point root.

Parameters:
  • ss – a storage service (that has a single mount point)

  • file – a file

Throws:

std::invalid_argument

Returns:

a file location specification

static std::shared_ptr<FileLocation> LOCATION(const std::shared_ptr<StorageService> &ss, const std::string &path, const std::shared_ptr<DataFile> &file)

File location specifier given an absolute path at a storage service.

Parameters:
  • ss – a storage service

  • file – a file

  • path – a path

Throws:

std::invalid_argument

Returns:

a file location specification

static bool properPathPrefix(const std::string &path1, const std::string &path2)

Helper method to find if a path is a proper prefix of another path.

Parameters:
  • path1 – a path (ALREADY SANITIZED)

  • path2 – another path (ALREADY SANITIZED)

Returns:

true if one of the two paths is a proper prefix of the other

static std::string sanitizePath(const std::string &path)

Method to sanitize an absolute path (and make it absolute if it’s not)

Parameters:

path – an absolute path

Returns:

a sanitized path

static std::shared_ptr<FileLocation> SCRATCH(const std::shared_ptr<DataFile> &file)

File location specifier for a scratch storage.

Parameters:

file – a file

Throws:

std::invalid_argument

Returns:

a file location specification