File: test_io.c

package info (click to toggle)
gxr 0.15.1-4.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,768 kB
  • sloc: ansic: 15,256; sh: 72; xml: 71; awk: 35; makefile: 12
file content (53 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download | duplicates (5)
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
/*
 * gxr
 * Copyright 2018 Collabora Ltd.
 * Author: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
 * SPDX-License-Identifier: MIT
 */

#include <glib.h>

#include "gxr.h"

#define CACHE_DIR "gxr"
#define RES_BASE_PATH "/res/bindings/openvr"

static gboolean
_cache_bindings (GString *actions_path)
{
  GString* cache_path = gxr_io_get_cache_path (CACHE_DIR);

  if (g_mkdir_with_parents (cache_path->str, 0700) == -1)
    {
      g_printerr ("Unable to create directory %s\n", cache_path->str);
      return FALSE;
    }

  if (!gxr_io_write_resource_to_file (RES_BASE_PATH, cache_path->str,
                                      "actions.json", actions_path))
    return FALSE;

  GString *bindings_path = g_string_new ("");
  if (!gxr_io_write_resource_to_file (RES_BASE_PATH, cache_path->str,
                                      "bindings_vive_controller.json",
                                      bindings_path))
    return FALSE;

  g_string_free (bindings_path, TRUE);
  g_string_free (cache_path, TRUE);

  return TRUE;
}

int
main ()
{
  GString *action_manifest_path = g_string_new ("");
  g_assert (_cache_bindings (action_manifest_path));

  g_print ("Created manifest file: %s\n", action_manifest_path->str);

  g_string_free (action_manifest_path, TRUE);

  return 0;
}