Difference between revisions of "Shell Commands/FileWrite"

From MorphOS Library

< Shell Commands

 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
'''FileWrite''' - Writes data to a file
 
'''FileWrite''' - Writes data to a file
  
File/A, Size/N/A, Data/N, String, Add/S
+
FILE/A, SIZE/N/A, DATA/N, STRING, ADD/S
 
  <nowiki>
 
  <nowiki>
File   - Filename to write data to
+
FILE   - Filename to write data to
Size   - Amount of data in bytes to be written
+
SIZE   - Amount of data in bytes to be written
Data   - Data to be written in hex
+
DATA   - Data to be written in hex
String - Data in the string format
+
STRING - Data in the string format
Add   - Adds data to an existing file instead of creating a new file
+
ADD   - Adds data to an existing file instead of creating a new file
 
</nowiki>
 
</nowiki>
 
If the length of data is shorter than the size value, the file is filled by repeating the data contents. Strings get separated by null bytes then. Data entered in decimals gets converted to hex. If no data is given, the file is filled with null bytes.
 
If the length of data is shorter than the size value, the file is filled by repeating the data contents. Strings get separated by null bytes then. Data entered in decimals gets converted to hex. If no data is given, the file is filled with null bytes.
Line 29: Line 29:
 
Ram Disk:> Type test HEX
 
Ram Disk:> Type test HEX
 
0000: 4D6F7270 4D6F7270                  MorpMorp
 
0000: 4D6F7270 4D6F7270                  MorpMorp
 +
</nowiki>
 +
 +
To create an empty ADF image (which can then be mounted with [[Tools/FileImageCtrl]] and formatted with [[Tools/Format]] under MorphOS, or just be used in an Amiga emulator):
 +
<nowiki>
 +
Ram Disk:> FileWrite empty.adf 901120
 +
</nowiki>
 +
 +
And similarly, creating an empty HDF image (100 megabytes in this case):
 +
<nowiki>
 +
Ram Disk: FileWrite harddisk.hdf `eval 100*1024*1024`
 
</nowiki>
 
</nowiki>

Latest revision as of 21:49, 19 July 2024

FileWrite - Writes data to a file

FILE/A, SIZE/N/A, DATA/N, STRING, ADD/S

FILE   - Filename to write data to
SIZE   - Amount of data in bytes to be written
DATA   - Data to be written in hex
STRING - Data in the string format
ADD    - Adds data to an existing file instead of creating a new file

If the length of data is shorter than the size value, the file is filled by repeating the data contents. Strings get separated by null bytes then. Data entered in decimals gets converted to hex. If no data is given, the file is filled with null bytes.

Examples:

Ram Disk:> FileWrite test 8 0x4d4f5321
Ram Disk:> Type test HEX
0000: 4D4F5321 4D4F5321                   MOS!MOS!

Ram Disk:> FileWrite test 32 STRING MorphOS
Ram Disk:> Type test HEX
0000: 4D6F7270 684F5300 4D6F7270 684F5300 MorphOS.MorphOS.
0010: 4D6F7270 684F5300 4D6F7270 684F5300 MorphOS.MorphOS.

Ram Disk:> FileWrite test 4 STRING MorphOS
Ram Disk:> Type test HEX
0000: 4D6F7270                            Morp

Ram Disk:> FileWrite test 4 STRING MorphOS ADD
Ram Disk:> Type test HEX
0000: 4D6F7270 4D6F7270                   MorpMorp

To create an empty ADF image (which can then be mounted with Tools/FileImageCtrl and formatted with Tools/Format under MorphOS, or just be used in an Amiga emulator):

Ram Disk:> FileWrite empty.adf 901120

And similarly, creating an empty HDF image (100 megabytes in this case):

Ram Disk: FileWrite harddisk.hdf `eval 100*1024*1024`