tesseract  4.00.00dev
basedir.h File Reference
#include "platform.h"
#include "strngs.h"

Go to the source code of this file.

Functions

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

Function Documentation

◆ truncate_path()

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

Definition at line 30 of file basedir.cpp.

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