~ubuntu-branches/ubuntu/intrepid/libcrypto++/intrepid

« back to all changes in this revision

Viewing changes to files.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Machard
  • Date: 2004-08-27 12:35:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040827123505-7evgxiu7k8memiyk
Tags: 5.2.1a-1
* Urgency set to high because lastest upload was unclean
* Rename libcrypto++-5.2.1.orig.tar.gz in  libcrypto++-5.2.1a.orig.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// files.cpp - written and placed in the public domain by Wei Dai
2
2
 
3
3
#include "pch.h"
 
4
 
 
5
#ifndef CRYPTOPP_IMPORTS
 
6
 
4
7
#include "files.h"
5
8
 
6
9
NAMESPACE_BEGIN(CryptoPP)
16
19
 
17
20
void FileStore::StoreInitialize(const NameValuePairs &parameters)
18
21
{
 
22
        m_file.reset(new std::ifstream);
19
23
        const char *fileName;
20
 
        if (parameters.GetValue("InputFileName", fileName))
 
24
        if (parameters.GetValue(Name::InputFileName(), fileName))
21
25
        {
22
 
                ios::openmode binary = parameters.GetValueWithDefault("InputBinaryMode", true) ? ios::binary : ios::openmode(0);
23
 
                m_file.open(fileName, ios::in | binary);
24
 
                if (!m_file)
 
26
                ios::openmode binary = parameters.GetValueWithDefault(Name::InputBinaryMode(), true) ? ios::binary : ios::openmode(0);
 
27
                m_file->open(fileName, ios::in | binary);
 
28
                if (!*m_file)
25
29
                        throw OpenErr(fileName);
26
 
                m_stream = &m_file;
 
30
                m_stream = m_file.get();
27
31
        }
28
32
        else
29
33
        {
30
34
                m_stream = NULL;
31
 
                parameters.GetValue("InputStreamPointer", m_stream);
 
35
                parameters.GetValue(Name::InputStreamPointer(), m_stream);
32
36
        }
33
37
        m_waiting = false;
34
38
}
137
141
        return 0;
138
142
}
139
143
 
 
144
unsigned long FileStore::Skip(unsigned long skipMax)
 
145
{
 
146
        unsigned long oldPos = m_stream->tellg();
 
147
        m_stream->seekg(skipMax, ios::cur);
 
148
        return (unsigned long)m_stream->tellg() - oldPos;
 
149
}
 
150
 
140
151
void FileSink::IsolatedInitialize(const NameValuePairs &parameters)
141
152
{
 
153
        m_file.reset(new std::ofstream);
142
154
        const char *fileName;
143
 
        if (parameters.GetValue("OutputFileName", fileName))
 
155
        if (parameters.GetValue(Name::OutputFileName(), fileName))
144
156
        {
145
 
                ios::openmode binary = parameters.GetValueWithDefault("OutputBinaryMode", true) ? ios::binary : ios::openmode(0);
146
 
                m_file.open(fileName, ios::out | ios::trunc | binary);
147
 
                if (!m_file)
 
157
                ios::openmode binary = parameters.GetValueWithDefault(Name::OutputBinaryMode(), true) ? ios::binary : ios::openmode(0);
 
158
                m_file->open(fileName, ios::out | ios::trunc | binary);
 
159
                if (!*m_file)
148
160
                        throw OpenErr(fileName);
149
 
                m_stream = &m_file;
 
161
                m_stream = m_file.get();
150
162
        }
151
163
        else
152
164
        {
153
165
                m_stream = NULL;
154
 
                parameters.GetValue("OutputStreamPointer", m_stream);
 
166
                parameters.GetValue(Name::OutputStreamPointer(), m_stream);
155
167
        }
156
168
}
157
169
 
184
196
}
185
197
 
186
198
NAMESPACE_END
 
199
 
 
200
#endif