Explorar o código

Merge pull request #72 from blitz-research/develop

Develop up
abakobo %!s(int64=8) %!d(string=hai) anos
pai
achega
e4f5e31ffc
Modificáronse 2 ficheiros con 35 adicións e 5 borrados
  1. 5 5
      modules/monkey/math.monkey2
  2. 30 0
      modules/std/filesystem/filesystem.monkey2

+ 5 - 5
modules/monkey/math.monkey2

@@ -69,16 +69,16 @@ Function ATan:Double( x:Double )="std::atan"
 
 #rem monkeydoc Computes the inverse tangent of a ratio.
 
-The function uses the signs of `x` and `y` to compute the correct sign for the result.
+Returns the inverse tangent of `y`/`x`, using the signs of the arguments to determine the quadrant of the result.
 
-@param `x` The numerator.
+@param `y` The numerator.
 
-@param `y` The denominator.
+@param `z` The denominator.
 
-@return The inverse tangent of `x`/`y`, in radians.
+@return The inverse tangent of `y`/`x`, in radians.
 
 #end
-Function ATan2:Double( x:Double,y:Double )="std::atan2"
+Function ATan2:Double( y:Double,x:Double )="std::atan2"
 
 #rem monkeydoc Computes the square root of a number.
 

+ 30 - 0
modules/std/filesystem/filesystem.monkey2

@@ -278,6 +278,35 @@ Function RealPath:String( path:String )
 	
 	path=FixRoot( path )
 	
+	Local rpath:=ExtractRootDir( path )
+	If rpath 
+		path=path.Slice( rpath.Length )
+	Else
+		rpath=CurrentDir()
+	Endif
+	
+	While path
+		Local i:=path.Find( "/" )
+		If i=-1 Return rpath+path
+		Local t:=path.Slice( 0,i )
+		path=path.Slice( i+1 )
+		Select t
+		Case ""
+		Case "."
+		Case ".."
+			If Not rpath rpath=CurrentDir()
+			rpath=ExtractDir( rpath )
+		Default
+			rpath+=t+"/"
+		End
+	Wend
+	
+	Return rpath
+	
+	#rem Not working on macos!
+	
+	path=FixRoot( path )
+	
 	Local buf:=New char_t[PATH_MAX]
 	
 	If Not libc.realpath( path,buf.Data ) Return ""
@@ -289,6 +318,7 @@ Function RealPath:String( path:String )
 #Endif
 
 	Return rpath
+	#end
 End
 
 #rem monkeydoc Strips any trailing slashes from a filesystem path.