summaryrefslogtreecommitdiff
path: root/embeddedcryptopp/files.h
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2013-08-22 16:39:52 -0400
committerMicah Anderson <micah@riseup.net>2013-08-22 16:39:52 -0400
commit5e60e0e3af85f22aa0afe8bf0ecf85619afacfeb (patch)
tree6a91a3de86fa8de0b4167cc947ab72991bf8da31 /embeddedcryptopp/files.h
parent30e9097985656920f01a72efc1088caa2b8d41b3 (diff)
Imported Upstream version 0.6.0.12upstream/0.6.0.12
Diffstat (limited to 'embeddedcryptopp/files.h')
-rw-r--r--embeddedcryptopp/files.h97
1 files changed, 0 insertions, 97 deletions
diff --git a/embeddedcryptopp/files.h b/embeddedcryptopp/files.h
deleted file mode 100644
index 2c4e2b8..0000000
--- a/embeddedcryptopp/files.h
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef CRYPTOPP_FILES_H
-#define CRYPTOPP_FILES_H
-
-#include "cryptlib.h"
-#include "filters.h"
-#include "argnames.h"
-
-#include <iostream>
-#include <fstream>
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! file-based implementation of Store interface
-class CRYPTOPP_DLL FileStore : public Store, private FilterPutSpaceHelper, public NotCopyable
-{
-public:
- class Err : public Exception
- {
- public:
- Err(const std::string &s) : Exception(IO_ERROR, s) {}
- };
- class OpenErr : public Err {public: OpenErr(const std::string &filename) : Err("FileStore: error opening file for reading: " + filename) {}};
- class ReadErr : public Err {public: ReadErr() : Err("FileStore: error reading file") {}};
-
- FileStore() : m_stream(NULL) {}
- FileStore(std::istream &in)
- {StoreInitialize(MakeParameters(Name::InputStreamPointer(), &in));}
- FileStore(const char *filename)
- {StoreInitialize(MakeParameters(Name::InputFileName(), filename));}
-
- std::istream* GetStream() {return m_stream;}
-
- lword MaxRetrievable() const;
- size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
- size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const;
- lword Skip(lword skipMax=ULONG_MAX);
-
-private:
- void StoreInitialize(const NameValuePairs &parameters);
-
- member_ptr<std::ifstream> m_file;
- std::istream *m_stream;
- byte *m_space;
- size_t m_len;
- bool m_waiting;
-};
-
-//! file-based implementation of Source interface
-class CRYPTOPP_DLL FileSource : public SourceTemplate<FileStore>
-{
-public:
- typedef FileStore::Err Err;
- typedef FileStore::OpenErr OpenErr;
- typedef FileStore::ReadErr ReadErr;
-
- FileSource(BufferedTransformation *attachment = NULL)
- : SourceTemplate<FileStore>(attachment) {}
- FileSource(std::istream &in, bool pumpAll, BufferedTransformation *attachment = NULL)
- : SourceTemplate<FileStore>(attachment) {SourceInitialize(pumpAll, MakeParameters(Name::InputStreamPointer(), &in));}
- FileSource(const char *filename, bool pumpAll, BufferedTransformation *attachment = NULL, bool binary=true)
- : SourceTemplate<FileStore>(attachment) {SourceInitialize(pumpAll, MakeParameters(Name::InputFileName(), filename)(Name::InputBinaryMode(), binary));}
-
- std::istream* GetStream() {return m_store.GetStream();}
-};
-
-//! file-based implementation of Sink interface
-class CRYPTOPP_DLL FileSink : public Sink, public NotCopyable
-{
-public:
- class Err : public Exception
- {
- public:
- Err(const std::string &s) : Exception(IO_ERROR, s) {}
- };
- class OpenErr : public Err {public: OpenErr(const std::string &filename) : Err("FileSink: error opening file for writing: " + filename) {}};
- class WriteErr : public Err {public: WriteErr() : Err("FileSink: error writing file") {}};
-
- FileSink() : m_stream(NULL) {}
- FileSink(std::ostream &out)
- {IsolatedInitialize(MakeParameters(Name::OutputStreamPointer(), &out));}
- FileSink(const char *filename, bool binary=true)
- {IsolatedInitialize(MakeParameters(Name::OutputFileName(), filename)("OutputBinaryMode", binary));}
-
- std::ostream* GetStream() {return m_stream;}
-
- void IsolatedInitialize(const NameValuePairs &parameters);
- size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
- bool IsolatedFlush(bool hardFlush, bool blocking);
-
-private:
- member_ptr<std::ofstream> m_file;
- std::ostream *m_stream;
-};
-
-NAMESPACE_END
-
-#endif