summaryrefslogtreecommitdiffstats
path: root/ipfs-cli/src/command/mod.rs
blob: c19236b1e6031dfd208cd86ddcf3628ee27c0723 (plain)
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
// Copyright 2017 rust-ipfs-api Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
//

use std::error::Error;
use std::fs;

pub const EXPECTED_API: &str = "expected response from API";
pub const EXPECTED_FILE: &str = "expected to read input file";

/// Verifies that a path points to a file that exists, and not a directory.
///
pub fn verify_file(path: String) -> Result<(), String> {
    match fs::metadata(path) {
        Ok(ref metadata) if metadata.is_file() => Ok(()),
        Ok(_) => Err("file must not be a directory".into()),
        Err(e) => Err(e.description().into()),
    }
}

pub mod add;
pub mod bitswap;
pub mod block;
pub mod bootstrap;
pub mod cat;
pub mod commands;
pub mod config;
pub mod dag;
pub mod dht;
pub mod diag;
pub mod dns;
pub mod file;
pub mod files;
pub mod filestore;
pub mod shutdown;
pub mod version;