----------------------------------------------------------------------------- Write to a file. The number of bytes to write is passed in size, the data is passed in src. The number of bytes written is available in bytesWritten if a non-Null pointer is provided. -----------------------------------------------------------------------------
| 785 | // pointer is provided. |
| 786 | //----------------------------------------------------------------------------- |
| 787 | File::FileStatus File::write(U32 size, const char *src, U32 *bytesWritten) |
| 788 | { |
| 789 | // JMQ: despite the U32 parameters, the maximum filesize supported by this |
| 790 | // function is probably the max value of S32, due to the unix syscall |
| 791 | // api. |
| 792 | AssertFatal(Closed != currentStatus, "File::write: file closed"); |
| 793 | AssertFatal(NULL != handle, "File::write: invalid file handle"); |
| 794 | AssertFatal(NULL != src, "File::write: NULL source pointer"); |
| 795 | AssertFatal(true == hasCapability(FileWrite), "File::write: file lacks capability"); |
| 796 | AssertWarn(0 != size, "File::write: size of zero"); |
| 797 | |
| 798 | if ((Ok != currentStatus && EOS != currentStatus) || 0 == size) |
| 799 | return currentStatus; |
| 800 | else |
| 801 | { |
| 802 | S32 numWritten = x86UNIXWrite(*((int *)handle), src, size); |
| 803 | if (numWritten < 0) |
| 804 | return setStatus(); |
| 805 | |
| 806 | if (bytesWritten) |
| 807 | *bytesWritten = static_cast<U32>(numWritten); |
| 808 | return currentStatus = Ok; |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | //----------------------------------------------------------------------------- |
| 813 | // Self-explanatory. JMQ: No explanation needed. Move along. These aren't |
nothing calls this directly
no test coverage detected