summaryrefslogtreecommitdiffstats
path: root/fastlib/src/vespa/fastlib/io/fileinputstream.cpp
blob: 21ee22987ce991e1f0dd21dce52877521d3ef70b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
*******************************************************************************
*
* @author Stein Hardy Danielsen
* @date            Creation date: 2000-10-07
* @version         $Id$
*
* @file
*
* FileInputStream class implementation
*
* Copyright (c)  : 1997-2000 Fast Search & Transfer ASA
*                  ALL RIGHTS RESERVED
*
******************************************************************************/
#include <vespa/fastos/fastos.h>
#include <limits.h>
#include <vespa/fastlib/io/fileinputstream.h>


Fast_FileInputStream::Fast_FileInputStream(const char *fileName)
    : _theFile(new FastOS_File(fileName)),
      _fileOpenedOk(false)
{
    _fileOpenedOk = _theFile->OpenReadOnly();
}

Fast_FileInputStream::~Fast_FileInputStream(void)
{
    Close();
    delete _theFile;
}

ssize_t
Fast_FileInputStream::Read(void *targetBuffer, size_t bufferSize)
{
    ssize_t retVal = -1;
    if (_fileOpenedOk) {
        retVal = _theFile->Read(targetBuffer, bufferSize);
    }
    return retVal;
};

bool
Fast_FileInputStream::Close() {
    return _theFile->Close();
}

ssize_t
Fast_FileInputStream::Available() {
    return 0;
}

ssize_t
Fast_FileInputStream::Skip(size_t) {
    return 0;
}