Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: import/cross/tar_processor.h

Issue 159129: Refactor tar code to support long names.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 29 matching lines...) Expand all
40 // As a TarProcessor receives bytes, it calls the client 40 // As a TarProcessor receives bytes, it calls the client
41 // callback method ReceiveFileHeader() when each complete file header has been 41 // callback method ReceiveFileHeader() when each complete file header has been
42 // received. Then the client's ReceiveFileData() will be called (possibly 42 // received. Then the client's ReceiveFileData() will be called (possibly
43 // repeatedly) as the file's data is received. This is repeated until all of 43 // repeatedly) as the file's data is received. This is repeated until all of
44 // the files in the archive have been processed. 44 // the files in the archive have been processed.
45 45
46 #ifndef O3D_IMPORT_CROSS_TAR_PROCESSOR_H_ 46 #ifndef O3D_IMPORT_CROSS_TAR_PROCESSOR_H_
47 #define O3D_IMPORT_CROSS_TAR_PROCESSOR_H_ 47 #define O3D_IMPORT_CROSS_TAR_PROCESSOR_H_
48 48
49 #include "base/basictypes.h" 49 #include "base/basictypes.h"
50 #include "core/cross/types.h"
50 #include "import/cross/memory_stream.h" 51 #include "import/cross/memory_stream.h"
51 #include "import/cross/archive_processor.h" 52 #include "import/cross/archive_processor.h"
52 53
53 namespace o3d { 54 namespace o3d {
54 55
55 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56 class TarProcessor : public StreamProcessor { 57 class TarProcessor : public StreamProcessor {
57 public: 58 public:
58 explicit TarProcessor(ArchiveCallbackClient *callback_client) 59 explicit TarProcessor(ArchiveCallbackClient *callback_client)
59 : callback_client_(callback_client), 60 : callback_client_(callback_client),
60 header_bytes_read_(0), 61 header_bytes_read_(0),
62 getting_filename_(false),
61 file_bytes_to_read_(0) {} 63 file_bytes_to_read_(0) {}
62 64
63 virtual ~TarProcessor() {} 65 virtual ~TarProcessor() {}
64 66
65 // Call to "push" bytes to be processed - the appropriate callback will get 67 // Call to "push" bytes to be processed - the appropriate callback will get
66 // called when we have enough data 68 // called when we have enough data
67 virtual int ProcessBytes(MemoryReadStream *stream, size_t n); 69 virtual int ProcessBytes(MemoryReadStream *stream, size_t n);
68 70
69 private: 71 private:
70 enum {TAR_HEADER_SIZE = 512}; 72 enum {TAR_HEADER_SIZE = 512};
71 enum {TAR_BLOCK_SIZE = 512}; 73 enum {TAR_BLOCK_SIZE = 512};
72 74
73 ArchiveCallbackClient *callback_client_; 75 ArchiveCallbackClient *callback_client_;
74 size_t header_bytes_read_; 76 size_t header_bytes_read_;
75 char header_[TAR_HEADER_SIZE]; 77 char header_[TAR_HEADER_SIZE];
78 bool getting_filename_;
79 String file_name_;
76 80
77 // Initialized to total number of file bytes, 81 // Initialized to total number of file bytes,
78 // including zero padding up to block size 82 // including zero padding up to block size
79 // We read this many bytes to get to the next header 83 // We read this many bytes to get to the next header
80 size_t file_bytes_to_read_; 84 size_t file_bytes_to_read_;
81 85
82 // Initialized to the actual file size (not counting zero-padding) - keeps 86 // Initialized to the actual file size (not counting zero-padding) - keeps
83 // track of number of bytes the client needs to read for the current file 87 // track of number of bytes the client needs to read for the current file
84 size_t client_file_bytes_to_read_; 88 size_t client_file_bytes_to_read_;
85 89
86 DISALLOW_COPY_AND_ASSIGN(TarProcessor); 90 DISALLOW_COPY_AND_ASSIGN(TarProcessor);
87 }; 91 };
88 92
89 } // namespace o3d 93 } // namespace o3d
90 94
91 #endif // O3D_IMPORT_CROSS_TAR_PROCESSOR_H_ 95 #endif // O3D_IMPORT_CROSS_TAR_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698