rnpgp / rnp

@@ -287,19 +287,6 @@
Loading
287 287
    return dest;
288 288
}
289 289
290 -
/* return the file modification time */
291 -
int64_t
292 -
rnp_filemtime(const char *path)
293 -
{
294 -
    struct stat st;
295 -
296 -
    if (stat(path, &st) != 0) {
297 -
        return 0;
298 -
    } else {
299 -
        return st.st_mtime;
300 -
    }
301 -
}
302 -
303 290
static char *
304 291
vcompose_path(char **buf, size_t *buf_len, const char *first, va_list ap)
305 292
{
@@ -427,13 +414,6 @@
Loading
427 414
    return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
428 415
}
429 416
430 -
bool
431 -
rnp_file_exists(const char *path)
432 -
{
433 -
    struct stat st;
434 -
    return stat(path, &st) == 0 && S_ISREG(st.st_mode);
435 -
}
436 -
437 417
bool
438 418
rnp_hex_encode(
439 419
  const uint8_t *buf, size_t buf_len, char *hex, size_t hex_len, rnp_hex_format_t format)
@@ -475,18 +455,6 @@
Loading
475 455
    return s;
476 456
}
477 457
478 -
char *
479 -
rnp_strip_eol(char *s)
480 -
{
481 -
    size_t len = strlen(s);
482 -
483 -
    while ((len > 0) && ((s[len - 1] == '\n') || (s[len - 1] == '\r'))) {
484 -
        s[--len] = '\0';
485 -
    }
486 -
487 -
    return s;
488 -
}
489 -
490 458
/* convert hex string, probably prefixes with 0x, to binary form */
491 459
bool
492 460
hex2bin(const char *hex, size_t hexlen, uint8_t *bin, size_t len, size_t *out)

@@ -0,0 +1,48 @@
Loading
1 +
/*
2 +
 * Copyright (c) 2017 [Ribose Inc](https://www.ribose.com).
3 +
 * All rights reserved.
4 +
 *
5 +
 * Redistribution and use in source and binary forms, with or without modification,
6 +
 * are permitted provided that the following conditions are met:
7 +
 *
8 +
 * 1.  Redistributions of source code must retain the above copyright notice,
9 +
 *     this list of conditions and the following disclaimer.
10 +
 *
11 +
 * 2.  Redistributions in binary form must reproduce the above copyright notice,
12 +
 *     this list of conditions and the following disclaimer in the documentation
13 +
 *     and/or other materials provided with the distribution.
14 +
 *
15 +
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 +
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 +
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 +
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
19 +
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 +
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 +
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 +
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 +
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 +
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 +
 */
26 +
/** String utilities
27 +
 *  @file
28 +
 */
29 +
30 +
#include "str-utils.h"
31 +
#include <cstddef>
32 +
#include <cstring>
33 +
34 +
using std::size_t;
35 +
using std::strlen;
36 +
37 +
char *
38 +
rnp_strip_eol(char *s)
39 +
{
40 +
    size_t len = strlen(s);
41 +
42 +
    while ((len > 0) && ((s[len - 1] == '\n') || (s[len - 1] == '\r'))) {
43 +
        s[--len] = '\0';
44 +
    }
45 +
46 +
    return s;
47 +
}
48 +

@@ -47,6 +47,8 @@
Loading
47 47
#include "config.h"
48 48
#include "fficli.h"
49 49
#include "utils.h"
50 +
#include "str-utils.h"
51 +
#include "file-utils.h"
50 52
51 53
// must be placed after include "utils.h"
52 54
#ifndef RNP_USE_STD_REGEX

@@ -0,0 +1,55 @@
Loading
1 +
/*
2 +
 * Copyright (c) 2017 [Ribose Inc](https://www.ribose.com).
3 +
 * All rights reserved.
4 +
 *
5 +
 * Redistribution and use in source and binary forms, with or without modification,
6 +
 * are permitted provided that the following conditions are met:
7 +
 *
8 +
 * 1.  Redistributions of source code must retain the above copyright notice,
9 +
 *     this list of conditions and the following disclaimer.
10 +
 *
11 +
 * 2.  Redistributions in binary form must reproduce the above copyright notice,
12 +
 *     this list of conditions and the following disclaimer in the documentation
13 +
 *     and/or other materials provided with the distribution.
14 +
 *
15 +
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 +
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 +
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 +
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
19 +
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 +
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 +
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 +
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 +
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 +
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 +
 */
26 +
/** File utilities
27 +
 *  @file
28 +
 */
29 +
30 +
#include "file-utils.h"
31 +
32 +
extern "C" {
33 +
#include <sys/stat.h>
34 +
}
35 +
36 +
bool
37 +
rnp_file_exists(const char *path)
38 +
{
39 +
    struct stat st;
40 +
    return stat(path, &st) == 0 && S_ISREG(st.st_mode);
41 +
}
42 +
43 +
/* return the file modification time */
44 +
int64_t
45 +
rnp_filemtime(const char *path)
46 +
{
47 +
    struct stat st;
48 +
49 +
    if (stat(path, &st) != 0) {
50 +
        return 0;
51 +
    } else {
52 +
        return st.st_mtime;
53 +
    }
54 +
}
55 +

@@ -54,6 +54,7 @@
Loading
54 54
#include "version.h"
55 55
#include <botan/secmem.h>
56 56
#include "ffi-priv-types.h"
57 +
#include "file-utils.h"
57 58
58 59
#define FFI_LOG(ffi, ...)            \
59 60
    do {                             \

@@ -37,6 +37,7 @@
Loading
37 37
#include <json.h>
38 38
#include <vector>
39 39
#include <string>
40 +
#include "file-utils.h"
40 41
41 42
TEST_F(rnp_tests, test_ffi_homedir)
42 43
{
Files Coverage
src 83.47%
include/rekey/rnp_key_store.h 100.00%
Project Totals (84 files) 83.47%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading