Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
basedir.cpp File Reference
#include "basedir.h"
#include <stdlib.h>
#include "mfcpch.h"

Go to the source code of this file.

Functions

TESS_API void truncate_path (const char *code_path, STRING *trunc_path)
 

Function Documentation

TESS_API void truncate_path ( const char *  code_path,
STRING trunc_path 
)

Definition at line 32 of file basedir.cpp.

32  {
33  int trunc_index = -1;
34  if (code_path != NULL) {
35  const char* last_slash = strrchr(code_path, '/');
36  if (last_slash != NULL && last_slash + 1 - code_path > trunc_index)
37  trunc_index = last_slash + 1 - code_path;
38  last_slash = strrchr(code_path, '\\');
39  if (last_slash != NULL && last_slash + 1 - code_path > trunc_index)
40  trunc_index = last_slash + 1 - code_path;
41  }
42  *trunc_path = code_path;
43  if (trunc_index >= 0)
44  trunc_path->truncate_at(trunc_index);
45  else
46  *trunc_path = "./";
47 }
void truncate_at(inT32 index)
Definition: strngs.cpp:223
#define NULL
Definition: host.h:144