tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccutil/basedir.cpp File Reference
#include "basedir.h"
#include <stdlib.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 30 of file basedir.cpp.

                                                                       {
  int trunc_index = -1;
  if (code_path != NULL) {
    const char* last_slash = strrchr(code_path, '/');
    if (last_slash != NULL && last_slash + 1 - code_path > trunc_index)
      trunc_index = last_slash + 1 - code_path;
    last_slash = strrchr(code_path, '\\');
    if (last_slash != NULL && last_slash + 1 - code_path > trunc_index)
      trunc_index = last_slash + 1 - code_path;
  }
  *trunc_path = code_path;
  if (trunc_index >= 0)
    trunc_path->truncate_at(trunc_index);
  else
    *trunc_path = "./";
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines