tesseract  4.0.0-1-g2a2b
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 29 of file basedir.cpp.

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