Path: blob/master/thirdparty/embree/common/sys/filename.h
9912 views
// Copyright 2009-2021 Intel Corporation1// SPDX-License-Identifier: Apache-2.023#pragma once45#include "platform.h"67namespace embree8{9/*! Convenience class for handling file names and paths. */10class FileName11{12public:1314/*! create an empty filename */15FileName ();1617/*! create a valid filename from a string */18FileName (const char* filename);1920/*! create a valid filename from a string */21FileName (const std::string& filename);2223/*! returns path to executable */24static FileName executableFolder();2526/*! auto convert into a string */27operator std::string() const { return filename; }2829/*! returns a string of the filename */30const std::string str() const { return filename; }3132/*! returns a c-string of the filename */33const char* c_str() const { return filename.c_str(); }3435/*! returns the path of a filename */36FileName path() const;3738/*! returns the file of a filename */39std::string base() const;4041/*! returns the base of a filename without extension */42std::string name() const;4344/*! returns the file extension */45std::string ext() const;4647/*! drops the file extension */48FileName dropExt() const;4950/*! replaces the file extension */51FileName setExt(const std::string& ext = "") const;5253/*! adds file extension */54FileName addExt(const std::string& ext = "") const;5556/*! concatenates two filenames to this/other */57FileName operator +( const FileName& other ) const;5859/*! concatenates two filenames to this/other */60FileName operator +( const std::string& other ) const;6162/*! removes the base from a filename (if possible) */63FileName operator -( const FileName& base ) const;6465/*! == operator */66friend bool operator==(const FileName& a, const FileName& b);6768/*! != operator */69friend bool operator!=(const FileName& a, const FileName& b);7071/*! output operator */72friend std::ostream& operator<<(std::ostream& cout, const FileName& filename);7374private:75std::string filename;76};77}787980