Blame libdjvu/GOS.h

Packit df99a1
//C-  -*- C++ -*-
Packit df99a1
//C- -------------------------------------------------------------------
Packit df99a1
//C- DjVuLibre-3.5
Packit df99a1
//C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
Packit df99a1
//C- Copyright (c) 2001  AT&T
Packit df99a1
//C-
Packit df99a1
//C- This software is subject to, and may be distributed under, the
Packit df99a1
//C- GNU General Public License, either Version 2 of the license,
Packit df99a1
//C- or (at your option) any later version. The license should have
Packit df99a1
//C- accompanied the software or you may obtain a copy of the license
Packit df99a1
//C- from the Free Software Foundation at http://www.fsf.org .
Packit df99a1
//C-
Packit df99a1
//C- This program is distributed in the hope that it will be useful,
Packit df99a1
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit df99a1
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit df99a1
//C- GNU General Public License for more details.
Packit df99a1
//C- 
Packit df99a1
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
Packit df99a1
//C- Lizardtech Software.  Lizardtech Software has authorized us to
Packit df99a1
//C- replace the original DjVu(r) Reference Library notice by the following
Packit df99a1
//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
Packit df99a1
//C-
Packit df99a1
//C-  ------------------------------------------------------------------
Packit df99a1
//C- | DjVu (r) Reference Library (v. 3.5)
Packit df99a1
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
Packit df99a1
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
Packit df99a1
//C- | 6,058,214 and patents pending.
Packit df99a1
//C- |
Packit df99a1
//C- | This software is subject to, and may be distributed under, the
Packit df99a1
//C- | GNU General Public License, either Version 2 of the license,
Packit df99a1
//C- | or (at your option) any later version. The license should have
Packit df99a1
//C- | accompanied the software or you may obtain a copy of the license
Packit df99a1
//C- | from the Free Software Foundation at http://www.fsf.org .
Packit df99a1
//C- |
Packit df99a1
//C- | The computer code originally released by LizardTech under this
Packit df99a1
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
Packit df99a1
//C- | ORIGINAL CODE."  Subject to any third party intellectual property
Packit df99a1
//C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
Packit df99a1
//C- | non-exclusive license to make, use, sell, or otherwise dispose of 
Packit df99a1
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
Packit df99a1
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
Packit df99a1
//C- | General Public License.   This grant only confers the right to 
Packit df99a1
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
Packit df99a1
//C- | the extent such infringement is reasonably necessary to enable 
Packit df99a1
//C- | recipient to make, have made, practice, sell, or otherwise dispose 
Packit df99a1
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
Packit df99a1
//C- | any greater extent that may be necessary to utilize further 
Packit df99a1
//C- | modifications or combinations.
Packit df99a1
//C- |
Packit df99a1
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
Packit df99a1
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
Packit df99a1
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
Packit df99a1
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Packit df99a1
//C- +------------------------------------------------------------------
Packit df99a1
Packit df99a1
#ifndef _GOS_H_
Packit df99a1
#define _GOS_H_
Packit df99a1
#ifdef HAVE_CONFIG_H
Packit df99a1
#include "config.h"
Packit df99a1
#endif
Packit df99a1
#if NEED_GNUG_PRAGMAS
Packit df99a1
# pragma interface
Packit df99a1
#endif
Packit df99a1
Packit df99a1
/** @name GOS.h
Packit df99a1
    Files #"GOS.h"# and #"GOS.cpp"# implement operating system 
Packit df99a1
    dependent functions with a unified interface.  All these functions
Packit df99a1
    are implemented as static member of class \Ref{GOS}. 
Packit df99a1
    Functions are provided for testing the presence of a file or a directory
Packit df99a1
    (\Ref{GOS::is_file}, \Ref{GOS::is_dir}), for manipulating file and directory names
Packit df99a1
    (\Ref{GOS::dirname}, \Ref{GOS::basename}, \Ref{GOS::expand_name},
Packit df99a1
    for obtaining and changing the current directory (\Ref{GOS::cwd}),
Packit df99a1
    for converting between file names and urls (\Ref{GOS::filename_to_url},
Packit df99a1
    \Ref{GOS::url_to_filename}), and for counting time (\Ref{GOS::ticks},
Packit df99a1
    \Ref{GOS::sleep}).
Packit df99a1
    
Packit df99a1
    @memo
Packit df99a1
    Operating System dependent functions.
Packit df99a1
    @author
Packit df99a1
    L\'eon Bottou <leonb@research.att.com> -- Initial implementation
Packit df99a1
*/
Packit df99a1
//@{
Packit df99a1
Packit df99a1
#include "DjVuGlobal.h"
Packit df99a1
#include "GString.h"
Packit df99a1
Packit df99a1
#ifdef HAVE_NAMESPACES
Packit df99a1
namespace DJVU {
Packit df99a1
# ifdef NOT_DEFINED // Just to fool emacs c++ mode
Packit df99a1
}
Packit df99a1
#endif
Packit df99a1
#endif
Packit df99a1
Packit df99a1
Packit df99a1
class GURL;
Packit df99a1
Packit df99a1
/** Operating System dependent functions. */
Packit df99a1
class DJVUAPI GOS 
Packit df99a1
{
Packit df99a1
 public:
Packit df99a1
  // -----------------------------------------
Packit df99a1
  // Functions for dealing with filenames
Packit df99a1
  // -----------------------------------------
Packit df99a1
Packit df99a1
  /** Returns the last component of file name #filename#.  If the filename
Packit df99a1
      suffix matches argument #suffix#, the filename suffix is removed.  This
Packit df99a1
      function works like the unix command #/bin/basename#, but also supports
Packit df99a1
      the naming conventions of other operating systems. */
Packit df99a1
  static GUTF8String basename(const GUTF8String &filename, const char *suffix=0);
Packit df99a1
Packit df99a1
  /** Sets and returns the current working directory.
Packit df99a1
      When argument #dirname# is specified, the current directory is changed
Packit df99a1
      to #dirname#. This function always returns the fully qualified name
Packit df99a1
      of the current directory. */
Packit df99a1
  static GUTF8String cwd(const GUTF8String &dirname=GUTF8String());
Packit df99a1
Packit df99a1
  // -----------------------------------------
Packit df99a1
  // Functions for measuring time
Packit df99a1
  // -----------------------------------------
Packit df99a1
  
Packit df99a1
  /** Returns a number of elapsed milliseconds.  This number counts elapsed
Packit df99a1
      milliseconds since a operating system dependent date. This function is
Packit df99a1
      useful for timing code. */
Packit df99a1
  static unsigned long ticks();
Packit df99a1
Packit df99a1
  /** Sleeps during the specified time expressed in milliseconds.
Packit df99a1
      Other threads can run while the calling thread sleeps. */
Packit df99a1
  static void sleep(int milliseconds);
Packit df99a1
Packit df99a1
  /// Read the named variable from the environment, and converts it to UTF8.
Packit df99a1
  static GUTF8String getenv(const GUTF8String &name);
Packit df99a1
Packit df99a1
#if 0
Packit df99a1
  // -------------------------------------------
Packit df99a1
  // Functions for converting filenames and urls
Packit df99a1
  // -------------------------------------------
Packit df99a1
  /** Encodes all reserved characters, so that the #filename# can be
Packit df99a1
      used inside a URL. Every reserved character is encoded using escape
Packit df99a1
      sequence in the form of #%XX#. The legal characters are alphanumeric and
Packit df99a1
      #$-_.+!*'(),:#.
Packit df99a1
      Use \Ref{decode_reserved}() to convert the URL back to the filename. */
Packit df99a1
//  static GString encode_reserved(const char * filename);
Packit df99a1
  static GString encode_mbcs_reserved(const char * filename);/*MBCS*/
Packit df99a1
#endif
Packit df99a1
Packit df99a1
};
Packit df99a1
Packit df99a1
Packit df99a1
//@}
Packit df99a1
// ------------
Packit df99a1
Packit df99a1
#ifdef HAVE_NAMESPACES
Packit df99a1
}
Packit df99a1
# ifndef NOT_USING_DJVU_NAMESPACE
Packit df99a1
using namespace DJVU;
Packit df99a1
# endif
Packit df99a1
#endif
Packit df99a1
#endif