Filename.st
changeset 7828 5167f23f77f6
parent 7776 e67e1ad8f5b5
child 7836 37309c372a91
equal deleted inserted replaced
7827:4f2f905d1c93 7828:5167f23f77f6
  2001     "
  2001     "
  2002 !
  2002 !
  2003 
  2003 
  2004 readStream
  2004 readStream
  2005     "return a stream for reading from the file represented by the receiver.
  2005     "return a stream for reading from the file represented by the receiver.
  2006      If the file does not already exist, nil is returned."
  2006      Raises an error if the file does not exist."
  2007 
  2007 
  2008     ^ FileStream readonlyFileNamed:(self osNameForAccess)
  2008     ^ FileStream readonlyFileNamed:(self osNameForAccess)
  2009 
  2009 
  2010     "
  2010     "
  2011      '/tmp/foo' asFilename readStream 
  2011      '/tmp/foo' asFilename readStream 
  2028     "
  2028     "
  2029 !
  2029 !
  2030 
  2030 
  2031 readWriteStream
  2031 readWriteStream
  2032     "return a stream for read/write the file represented by the receiver.
  2032     "return a stream for read/write the file represented by the receiver.
  2033      If the file does not already exist, nil is returned.
  2033      If the file does not already exist, it is created.
  2034      If the file does exist, it is NOT truncated."
  2034      If the file does exist, it is NOT truncated, but rewritten at the beginning."
  2035 
  2035 
  2036     ^ FileStream fileNamed:(self osNameForAccess)
  2036     ^ FileStream fileNamed:(self osNameForAccess)
  2037 
  2037 
  2038     "
  2038     "
  2039      |s|
  2039      |s|
  2040 
  2040 
  2041      s := '/tmp/foo' asFilename writeStream.
  2041      s := '/tmp/foo' asFilename writeStream.
  2042      s nextPutAll:'1234567890'.
  2042      s nextPutAll:'1234567890'.
  2043      s close.
  2043      s close.
  2044 
  2044 
  2045      s := '/tmp/foo' asFilename readWriteStream.
  2045      s := '/tmp/foo' asFilename readWriteStream. 
  2046      s nextPutAll:'abcdef'.
  2046      s nextPutAll:'abcdef'.
  2047      s close.
  2047      s close.
  2048 
  2048 
  2049      '/tmp/foo' asFilename contents      
  2049      '/tmp/foo' asFilename contents      
       
  2050      '/tmp/foo' asFilename remove      
  2050     "
  2051     "
  2051 !
  2052 !
  2052 
  2053 
  2053 writeStream
  2054 writeStream
  2054     "return a stream for writing to the file represented by the receiver.
  2055     "return a stream for writing to the file represented by the receiver.
  4983 ! !
  4984 ! !
  4984 
  4985 
  4985 !Filename class methodsFor:'documentation'!
  4986 !Filename class methodsFor:'documentation'!
  4986 
  4987 
  4987 version
  4988 version
  4988     ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.270 2003-11-22 17:05:22 cg Exp $'
  4989     ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.271 2004-01-14 14:07:50 cg Exp $'
  4989 ! !
  4990 ! !
  4990 
  4991 
  4991 Filename initialize!
  4992 Filename initialize!