3 Copyright (C) 2006-2008 Jörg Pfähler
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <lightOS/lightOS.hpp>
23 using namespace lightOS
;
32 if (fread(&buf
, 1, 1, stdin
) != 1)
37 int main(int argc
, char **argv
)
39 if (argc
== 1)show_stdin();
42 for (int i
=1;i
< argc
;i
++)
44 if (strcmp(argv
[i
], "-") == 0)
48 file
File(argv
[i
], access::read
);
51 if (File
.filetype() == file::block
)
53 if (File
.blockcount() != 0)
55 size_t size
= File
.blocksize() * File
.blockcount();
56 auto_array
<char> data(new char[size
+1]);
57 if (File
.read(data
.get(), 0, size
) != size
)return -1;
58 data
.get()[size
] = '\0';
62 else cerr
<< "cat: \"" << argv
[i
] << "\" is not a block file" << endl
;
64 else cerr
<< "cat: could not open the file \"" << argv
[i
] << "\"" << endl
;