瀏覽代碼

Moved sdl_rwstream to std.

Mark Sibly 8 年之前
父節點
當前提交
e1531789a2
共有 2 個文件被更改,包括 0 次插入170 次删除
  1. 0 152
      modules/mojo/app/sdl_rwstream.monkey2
  2. 0 18
      modules/mojo/mojo.monkey2

+ 0 - 152
modules/mojo/app/sdl_rwstream.monkey2

@@ -1,152 +0,0 @@
-
-Namespace std.stream
-
-Using sdl2
-
-Class SDL_RWStream Extends Stream
-
-	#rem monkeydoc True if no more data can be read from the stream.
-	
-	You can still write to a filestream even if `Eof` is true - disk space permitting!
-	
-	#end
-	Property Eof:Bool() Override
-		Return _pos>=_end
-	End
-
-	#rem monkeydoc Current filestream position.
-	
-	The current file read/write position.
-	
-	#end
-	Property Position:Int() Override
-		Return _pos
-	End
-
-	#rem monkeydoc Current filestream length.
-	
-	The length of the filestream. This is the same as the length of the file.
-	
-	The file length can increase if you write past the end of the file.
-	
-	#end	
-	Property Length:Int() Override
-		Return _end
-	End
-	
-	#rem monkeydoc Closes the filestream.
-	
-	Closing the filestream also sets its position and length to 0.
-	
-	#end
-	Method OnClose() Override
-		If Not _rwops Return
-		SDL_RWclose( _rwops )
-		_rwops=Null
-		_pos=0
-		_end=0
-	End
-	
-	#rem monkeydoc Seeks to a position in the filestream.
-	
-	@param offset The position to seek to.
-	
-	#end
-	Method Seek( position:Int ) Override
-
-		DebugAssert( position>=0 And position<=_end )
-		
-		SDL_RWseek( _rwops,position,RW_SEEK_SET )
-		
-		DebugAssert( SDL_RWtell( _rwops )=position )
-		
-		_pos=position
-	End
-	
-	#rem monkeydoc Reads data from the filestream.
-	
-	@param buf A pointer to the memory to read the data into.
-	
-	@param count The number of bytes to read.
-	
-	@return The number of bytes actually read.
-	
-	#end
-	Method Read:Int( buf:Void Ptr,count:Int ) Override
-	
-		count=Clamp( count,0,_end-_pos )
-		
-		count=SDL_RWread( _rwops,buf,1,count )
-		
-		DebugAssert( SDL_RWtell( _rwops )=_pos+count )
-		
-		_pos+=count
-		
-		Return count
-	End
-	
-	#rem monkeydoc Writes data to the filestream.
-	
-	Writing past the end of the file will increase the length of a filestream.
-	
-	@param buf A pointer to the memory to write the data from.
-	
-	@param count The number of bytes to write.
-	
-	@return The number of bytes actually written.
-	
-	#end
-	Method Write:Int( buf:Void Ptr,count:Int ) Override
-	
-		If count<=0 Return 0
-		
-		count=SDL_RWwrite( _rwops,buf,1,count )
-		
-		DebugAssert( SDL_RWtell( _rwops )=_pos+count )
-		
-		_pos+=count
-		
-		Return count
-	End
-	
-	#rem monkeydoc Opens a file and returns a new filestream.
-	
-	@param path The path of the file to open.
-	
-	@param mode The mode to open the file in: "r", "w" or "rw".
-	
-	@return A new filestream, or null if the file could not be opened.
-	
-	#end
-	Function Open:SDL_RWStream( path:String,mode:String )
-	
-		Select mode
-		Case "r"
-			mode="rb"
-		Case "w"
-			mode="wb"
-		Case "rw"
-			mode="W+b"
-		Default
-			Return Null
-		End
-		
-		Local rwops:=SDL_RWFromFile( path,mode )
-		If Not rwops Return Null
-		
-		Return New SDL_RWStream( rwops )
-	End
-	
-	Private
-	
-	Field _rwops:SDL_RWops Ptr
-	Field _pos:Int
-	Field _end:Int
-	
-	Method New( rwops:SDL_RWops Ptr )
-		_rwops=rwops
-		_pos=SDL_RWtell( _rwops )
-		_end=SDL_RWsize( _rwops )
-	End
-
-End

+ 0 - 18
modules/mojo/mojo.monkey2

@@ -20,8 +20,6 @@ Namespace mojo
 #Import "app/window"
 #Import "app/glwindow"
 
-#Import "app/sdl_rwstream.monkey2"
-
 'core graphics stuff
 #Import "graphics/glexts/glexts"
 #Import "graphics/glutil"
@@ -82,20 +80,4 @@ Function Main()
 		Return Stream.Open( "asset::themes/"+path,mode )
 	End
 	
-#if __TARGET__="android"
-
-	Stream.OpenFuncs["asset"]=Lambda:Stream( proto:String,path:String,mode:String )
-	
-		Return SDL_RWStream.Open( path,mode )
-	End
-
-#else if __TARGET__="ios"
-
-	Stream.OpenFuncs["asset"]=Lambda:Stream( proto:String,path:String,mode:String )
-	
-		Return SDL_RWStream.Open( "assets/"+path,mode )
-	End
-	
-#endif
-	
 End