aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-04-12 17:50:37 +0000
committerMike Buland <eichlan@xagasoft.com>2010-04-12 17:50:37 +0000
commitfc2943ed980306244749d8d13796eaff690917b6 (patch)
tree78e2c058295b76299f9e1c9560d150e0f124f640 /src/tools
parent41c9581b48f055f6559335ffc0316f27ed1b3657 (diff)
downloadlibbu++-fc2943ed980306244749d8d13796eaff690917b6.tar.gz
libbu++-fc2943ed980306244749d8d13796eaff690917b6.tar.bz2
libbu++-fc2943ed980306244749d8d13796eaff690917b6.tar.xz
libbu++-fc2943ed980306244749d8d13796eaff690917b6.zip
Wow Myriad!!
Myriad seems to work. I have to run it through a few more paces, and there are some known corner cases that I may just disallow, such as too-small block sizes. Beyond a little more testing, it's ready for production. I may switch some of my cache tests to using it now.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/myriad.cpp49
1 files changed, 42 insertions, 7 deletions
diff --git a/src/tools/myriad.cpp b/src/tools/myriad.cpp
index 95b4503..605aac9 100644
--- a/src/tools/myriad.cpp
+++ b/src/tools/myriad.cpp
@@ -20,7 +20,8 @@ enum Mode
20 modeCreate, 20 modeCreate,
21 modeInfo, 21 modeInfo,
22 modeStreamNew, 22 modeStreamNew,
23 modeStreamRead, 23 modeStreamDump,
24 modeStreamPut,
24 25
25 modeNone 26 modeNone
26}; 27};
@@ -41,8 +42,10 @@ public:
41 "Display some info about a Myriad file." ); 42 "Display some info about a Myriad file." );
42 addOption( eMode, 'n', "new", 43 addOption( eMode, 'n', "new",
43 "Create a new sub-stream in a Myriad file."); 44 "Create a new sub-stream in a Myriad file.");
44 addOption( eMode, 'r', "read", 45 addOption( eMode, 'd', "dump",
45 "Read a stream from a Myriad file."); 46 "Read a stream from a Myriad file.");
47 addOption( eMode, "put",
48 "Put a file into a Myriad stream.");
46 addHelpOption(); 49 addHelpOption();
47 50
48 addHelpBanner("\nGeneral options:"); 51 addHelpBanner("\nGeneral options:");
@@ -56,7 +59,8 @@ public:
56 setOverride( "create", "create" ); 59 setOverride( "create", "create" );
57 setOverride( "info", "info" ); 60 setOverride( "info", "info" );
58 setOverride( "new", "new" ); 61 setOverride( "new", "new" );
59 setOverride( "read", "read" ); 62 setOverride( "dump", "dump" );
63 setOverride( "put", "put" );
60 64
61 parse( argc, argv ); 65 parse( argc, argv );
62 } 66 }
@@ -78,8 +82,10 @@ Bu::Formatter &operator>>( Bu::Formatter &f, Mode &m )
78 m = modeInfo; 82 m = modeInfo;
79 else if( sTok == "new" ) 83 else if( sTok == "new" )
80 m = modeStreamNew; 84 m = modeStreamNew;
81 else if( sTok == "read" ) 85 else if( sTok == "dump" )
82 m = modeStreamRead; 86 m = modeStreamDump;
87 else if( sTok == "put" )
88 m = modeStreamPut;
83 else 89 else
84 m = modeNone; 90 m = modeNone;
85 return f; 91 return f;
@@ -99,7 +105,7 @@ int main( int argc, char *argv[] )
99 } 105 }
100 else 106 else
101 { 107 {
102 File fOut( opts.sFile, File::WriteNew ); 108 File fOut( opts.sFile, File::WriteNew|File::Read );
103 Myriad m( fOut ); 109 Myriad m( fOut );
104 m.initialize( opts.iBlockSize, opts.iPreallocate ); 110 m.initialize( opts.iBlockSize, opts.iPreallocate );
105 } 111 }
@@ -134,7 +140,7 @@ int main( int argc, char *argv[] )
134 } 140 }
135 break; 141 break;
136 142
137 case modeStreamRead: 143 case modeStreamDump:
138 if( !opts.sFile.isSet() ) 144 if( !opts.sFile.isSet() )
139 { 145 {
140 sio << "Please specify a file manipulate." << sio.nl; 146 sio << "Please specify a file manipulate." << sio.nl;
@@ -173,6 +179,35 @@ int main( int argc, char *argv[] )
173 } 179 }
174 sio << sio.nl; 180 sio << sio.nl;
175 } 181 }
182 sio << "Position: " << s.tell() << ", isEos()=" << s.isEos()
183 << sio.nl;
184 }
185 break;
186
187 case modeStreamPut:
188 if( !opts.sFile.isSet() )
189 {
190 sio << "Please specify a file manipulate." << sio.nl;
191 return 0;
192 }
193 else if( !opts.sSrc.isSet() )
194 {
195 sio << "Please specify a source file to read." << sio.nl;
196 }
197 else
198 {
199 File fOut( opts.sFile, File::Write|File::Read );
200 Myriad m( fOut );
201 m.initialize();
202 MyriadStream sOut = m.openStream(
203 m.createStream( opts.iPreallocate )
204 );
205 File fIn( opts.sSrc, File::Read );
206 char buf[1024];
207 while( !fIn.isEos() )
208 {
209 sOut.write( buf, fIn.read( buf, 1024 ) );
210 }
176 } 211 }
177 break; 212 break;
178 213