|
| 1 | +/* |
| 2 | + * Copyright 2020-present Daniel Trugman |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#include <string> |
| 18 | + |
| 19 | +#include "pfs/defer.hpp" |
| 20 | +#include "pfs/parsers/common.hpp" |
| 21 | +#include "pfs/parsers/generic.hpp" |
| 22 | +#include "pfs/block_queue.hpp" |
| 23 | + |
| 24 | +namespace pfs { |
| 25 | + |
| 26 | +using namespace impl; |
| 27 | + |
| 28 | +const std::string block_queue::QUEUE_DIR("queue/"); |
| 29 | + |
| 30 | +block_queue::block_queue(const std::string& block_root) |
| 31 | + : _block_queue_root(build_block_queue_root(block_root)) |
| 32 | +{} |
| 33 | + |
| 34 | +std::string block_queue::build_block_queue_root(const std::string& block_root) |
| 35 | +{ |
| 36 | + return block_root + QUEUE_DIR; |
| 37 | +} |
| 38 | + |
| 39 | +const std::string& block_queue::dir() const |
| 40 | +{ |
| 41 | + return _block_queue_root; |
| 42 | +} |
| 43 | + |
| 44 | +bool block_queue::get_rotational() const |
| 45 | +{ |
| 46 | + static const std::string SIZE_FILE("rotational"); |
| 47 | + auto path = _block_queue_root + SIZE_FILE; |
| 48 | + |
| 49 | + auto value = utils::readline(path); |
| 50 | + |
| 51 | + int number; |
| 52 | + parsers::to_number(value, number, utils::base::decimal); |
| 53 | + return number != 0; |
| 54 | +} |
| 55 | + |
| 56 | +} // namespace pfs |
0 commit comments