proxygen
folly::portability Namespace Reference

Namespaces

 sockets
 
 ssl
 

Functions

char * internal_dirname (char *path)
 

Variables

static char mutableDot [] = {'.', '\0'}
 

Function Documentation

char * folly::portability::internal_dirname ( char *  path)

Definition at line 24 of file Libgen.cpp.

References mutableDot.

Referenced by TEST().

24  {
25  if (path == nullptr || !strcmp(path, "")) {
26  return mutableDot;
27  }
28  if (!strcmp(path, "/") || !strcmp(path, "\\")) {
29  return path;
30  }
31 
32  size_t len = strlen(path);
33  if (path[len - 1] == '/' || path[len - 1] == '\\') {
34  path[len - 1] = '\0';
35  }
36 
37  char* pos = strrchr(path, '/');
38  if (strrchr(path, '\\') > pos) {
39  pos = strrchr(path, '\\');
40  }
41  if (pos == nullptr) {
42  return mutableDot;
43  }
44 
45  if (pos == path) {
46  *(pos + 1) = '\0';
47  } else {
48  *pos = '\0';
49  }
50  return path;
51 }
static char mutableDot[]
Definition: Libgen.cpp:23

Variable Documentation

char folly::portability::mutableDot[] = {'.', '\0'}
static

Definition at line 23 of file Libgen.cpp.

Referenced by internal_dirname().