source: trunk/libdjvu/GOS.h @ 269

Last change on this file since 269 was 206, checked in by Eugene Romanenko, 14 years ago

DJVU plugin: djvulibre updated to version 3.5.19

File size: 6.5 KB
Line 
1//C-  -*- C++ -*-
2//C- -------------------------------------------------------------------
3//C- DjVuLibre-3.5
4//C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
5//C- Copyright (c) 2001  AT&T
6//C-
7//C- This software is subject to, and may be distributed under, the
8//C- GNU General Public License, either Version 2 of the license,
9//C- or (at your option) any later version. The license should have
10//C- accompanied the software or you may obtain a copy of the license
11//C- from the Free Software Foundation at http://www.fsf.org .
12//C-
13//C- This program is distributed in the hope that it will be useful,
14//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
15//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16//C- GNU General Public License for more details.
17//C-
18//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
19//C- Lizardtech Software.  Lizardtech Software has authorized us to
20//C- replace the original DjVu(r) Reference Library notice by the following
21//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
22//C-
23//C-  ------------------------------------------------------------------
24//C- | DjVu (r) Reference Library (v. 3.5)
25//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
26//C- | The DjVu Reference Library is protected by U.S. Pat. No.
27//C- | 6,058,214 and patents pending.
28//C- |
29//C- | This software is subject to, and may be distributed under, the
30//C- | GNU General Public License, either Version 2 of the license,
31//C- | or (at your option) any later version. The license should have
32//C- | accompanied the software or you may obtain a copy of the license
33//C- | from the Free Software Foundation at http://www.fsf.org .
34//C- |
35//C- | The computer code originally released by LizardTech under this
36//C- | license and unmodified by other parties is deemed "the LIZARDTECH
37//C- | ORIGINAL CODE."  Subject to any third party intellectual property
38//C- | claims, LizardTech grants recipient a worldwide, royalty-free,
39//C- | non-exclusive license to make, use, sell, or otherwise dispose of
40//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the
41//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU
42//C- | General Public License.   This grant only confers the right to
43//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to
44//C- | the extent such infringement is reasonably necessary to enable
45//C- | recipient to make, have made, practice, sell, or otherwise dispose
46//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to
47//C- | any greater extent that may be necessary to utilize further
48//C- | modifications or combinations.
49//C- |
50//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
51//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
52//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
53//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
54//C- +------------------------------------------------------------------
55//
56// $Id: GOS.h,v 1.9 2007/03/25 20:48:32 leonb Exp $
57// $Name: release_3_5_19 $
58
59#ifndef _GOS_H_
60#define _GOS_H_
61#ifdef HAVE_CONFIG_H
62#include "config.h"
63#endif
64#if NEED_GNUG_PRAGMAS
65# pragma interface
66#endif
67
68/** @name GOS.h
69    Files #"GOS.h"# and #"GOS.cpp"# implement operating system
70    dependent functions with a unified interface.  All these functions
71    are implemented as static member of class \Ref{GOS}.
72    Functions are provided for testing the presence of a file or a directory
73    (\Ref{GOS::is_file}, \Ref{GOS::is_dir}), for manipulating file and directory names
74    (\Ref{GOS::dirname}, \Ref{GOS::basename}, \Ref{GOS::expand_name},
75    for obtaining and changing the current directory (\Ref{GOS::cwd}),
76    for converting between file names and urls (\Ref{GOS::filename_to_url},
77    \Ref{GOS::url_to_filename}), and for counting time (\Ref{GOS::ticks},
78    \Ref{GOS::sleep}).
79   
80    @memo
81    Operating System dependent functions.
82    @author
83    L\'eon Bottou <leonb@research.att.com> -- Initial implementation
84    @version
85    #$Id: GOS.h,v 1.9 2007/03/25 20:48:32 leonb Exp $#
86*/
87//@{
88
89#include "DjVuGlobal.h"
90#include "GString.h"
91
92#ifdef HAVE_NAMESPACES
93namespace DJVU {
94# ifdef NOT_DEFINED // Just to fool emacs c++ mode
95}
96#endif
97#endif
98
99
100class GURL;
101
102/** Operating System dependent functions. */
103class GOS
104{
105 public:
106  // -----------------------------------------
107  // Functions for dealing with filenames
108  // -----------------------------------------
109
110  /** Returns the last component of file name #filename#.  If the filename
111      suffix matches argument #suffix#, the filename suffix is removed.  This
112      function works like the unix command #/bin/basename#, but also supports
113      the naming conventions of other operating systems. */
114  static GUTF8String basename(const GUTF8String &filename, const char *suffix=0);
115
116  /** Sets and returns the current working directory.
117      When argument #dirname# is specified, the current directory is changed
118      to #dirname#. This function always returns the fully qualified name
119      of the current directory. */
120  static GUTF8String cwd(const GUTF8String &dirname=GUTF8String());
121
122  // -----------------------------------------
123  // Functions for measuring time
124  // -----------------------------------------
125 
126  /** Returns a number of elapsed milliseconds.  This number counts elapsed
127      milliseconds since a operating system dependent date. This function is
128      useful for timing code. */
129  static unsigned long ticks();
130
131  /** Sleeps during the specified time expressed in milliseconds.
132      Other threads can run while the calling thread sleeps. */
133  static void sleep(int milliseconds);
134
135  /// Read the named variable from the environment, and converts it to UTF8.
136  static GUTF8String getenv(const GUTF8String &name);
137
138#if 0
139  // -------------------------------------------
140  // Functions for converting filenames and urls
141  // -------------------------------------------
142  /** Encodes all reserved characters, so that the #filename# can be
143      used inside a URL. Every reserved character is encoded using escape
144      sequence in the form of #%XX#. The legal characters are alphanumeric and
145      #$-_.+!*'(),:#.
146      Use \Ref{decode_reserved}() to convert the URL back to the filename. */
147//  static GString encode_reserved(const char * filename);
148  static GString encode_mbcs_reserved(const char * filename);/*MBCS*/
149#endif
150
151};
152
153
154//@}
155// ------------
156
157#ifdef HAVE_NAMESPACES
158}
159# ifndef NOT_USING_DJVU_NAMESPACE
160using namespace DJVU;
161# endif
162#endif
163#endif
Note: See TracBrowser for help on using the repository browser.