monotone

monotone Mtn Source Tree

Root/platform.hh

1#ifndef __PLATFORM_HH__
2#define __PLATFORM_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13// this describes functions to be found, alternatively, in win32/* or unix/*
14// directories.
15
16#include "config.h"
17
18#include <string>
19
20#include "vocab.hh"
21#include "paths.hh"
22
23void read_password(std::string const & prompt, char * buf, size_t bufsz);
24void get_system_flavour(std::string & ident);
25bool is_executable(const char *path);
26
27// For LUA
28int existsonpath(const char *exe);
29int make_executable(const char *path);
30pid_t process_spawn(const char * const argv[]);
31int process_wait(pid_t pid, int *res, int timeout = -1);// default infinite
32int process_kill(pid_t pid, int signal);
33int process_sleep(unsigned int seconds);
34
35// stop "\n"->"\r\n" from breaking automate on Windows
36void make_io_binary();
37
38#ifdef WIN32
39std::string munge_argv_into_cmdline(const char* const argv[]);
40#endif
41// for term selection
42bool have_smart_terminal();
43// this function cannot call W/P/L, because it is called by the tick printing
44// code.
45// return value of 0 means "unlimited"
46unsigned int terminal_width();
47
48// for "reckless mode" workspace change detection.
49// returns 'true' if it has generated a valid inodeprint; returns 'false' if
50// there was a problem, in which case we should act as if the inodeprint has
51// changed.
52bool inodeprint_file(file_path const & file, hexenc<inodeprint> & ip);
53
54// for netsync 'serve' pidfile support
55pid_t get_process_id();
56
57// filesystem stuff
58// FIXME: BUG: this returns a string in the filesystem charset/encoding
59std::string get_current_working_dir();
60// calls N() if fails
61void change_current_working_dir(any_path const & to);
62utf8 tilde_expand(utf8 const & path);
63system_path get_default_confdir();
64utf8 get_homedir();
65namespace path
66{
67 typedef enum { nonexistent, directory, file } status;
68};
69path::status get_path_status(any_path const & path);
70
71void rename_clobberingly(any_path const & from, any_path const & to);
72
73// strerror wrapper for OS-specific errors (e.g. use FormatMessage on Win32)
74std::string os_strerror(os_err_t errnum);
75
76// Local Variables:
77// mode: C++
78// fill-column: 76
79// c-file-style: "gnu"
80// indent-tabs-mode: nil
81// End:
82// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
83
84#endif // __PLATFORM_HH__

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status