瀏覽代碼

filepath: Added clear and isEmpty methods.

Branimir Karadžić 8 年之前
父節點
當前提交
ae8fd89b62
共有 2 個文件被更改,包括 19 次插入0 次删除
  1. 6 0
      include/bx/filepath.h
  2. 13 0
      src/filepath.cpp

+ 6 - 0
include/bx/filepath.h

@@ -56,6 +56,9 @@ namespace bx
 		///
 		FilePath& operator=(const StringView& _rhs);
 
+		///
+		void clear();
+
 		///
 		void set(Dir::Enum _dir);
 
@@ -87,6 +90,9 @@ namespace bx
 		///
 		bool isAbsolute() const;
 
+		///
+		bool isEmpty() const;
+
 	private:
 		char m_filePath[kMaxFilePath];
 	};

+ 13 - 0
src/filepath.cpp

@@ -275,6 +275,14 @@ namespace bx
 		return *this;
 	}
 
+	void FilePath::clear()
+	{
+		if (!isEmpty() )
+		{
+			set("");
+		}
+	}
+
 	void FilePath::set(Dir::Enum _dir)
 	{
 		char tmp[kMaxFilePath];
@@ -384,6 +392,11 @@ namespace bx
 			;
 	}
 
+	bool FilePath::isEmpty() const
+	{
+		return 0 == strCmp(m_filePath, ".");
+	}
+
 	bool make(const FilePath& _filePath, Error* _err)
 	{
 		BX_ERROR_SCOPE(_err);