Kaynağa Gözat

Add is_root_path() and is_absolute_path()

Daniele Bartolini 12 yıl önce
ebeveyn
işleme
2cb4108d0e
2 değiştirilmiş dosya ile 38 ekleme ve 0 silme
  1. 6 0
      src/os/OS.h
  2. 32 0
      src/os/linux/LinuxOS.cpp

+ 6 - 0
src/os/OS.h

@@ -84,6 +84,12 @@ void			log_error(const char* string, va_list arg);		//!< Print error message
 void			log_warning(const char* string, va_list arg);	//!< Print warning message
 void			log_info(const char* string, va_list arg);		//!< Print info message
 
+//-----------------------------------------------------------------------------
+// Paths
+//-----------------------------------------------------------------------------
+bool			is_root_path(const char* path);
+bool			is_absolute_path(const char* path);
+
 //-----------------------------------------------------------------------------
 // File management
 //-----------------------------------------------------------------------------

+ 32 - 0
src/os/linux/LinuxOS.cpp

@@ -92,6 +92,38 @@ void log_info(const char* string, va_list arg)
 	printf("\n");
 }
 
+//-----------------------------------------------------------------------------
+bool is_root_path(const char* path)
+{
+	assert(path != NULL);
+
+	if (string::strlen(path) == 1)
+	{
+		if (path[0] == PATH_SEPARATOR)
+		{
+			return true;
+		}
+	}
+
+	return false;
+}
+
+//-----------------------------------------------------------------------------
+bool is_absolute_path(const char* path)
+{
+	assert(path != NULL);
+
+	if (string::strlen(path) > 0)
+	{
+		if (path[0] == PATH_SEPARATOR)
+		{
+			return true;
+		}
+	}
+
+	return false;
+}
+
 //-----------------------------------------------------------------------------
 bool exists(const char* path)
 {