aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/progname.cpp
blob: 99c562c7e6fef76f5dd92b322a4afc29f3cfb629 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "execpath.h"
#include "progname.h" 
 
#include <util/folder/dirut.h> 
#include <util/generic/singleton.h> 
 
static const char* Argv0; 

namespace { 
    struct TProgramNameHolder { 
        inline TProgramNameHolder() 
            : ProgName(GetFileNameComponent(Argv0 ? Argv0 : GetExecPath().data()))
        { 
        } 
 
        TString ProgName;
    }; 
} 
 
const TString& GetProgramName() {
    return Singleton<TProgramNameHolder>()->ProgName;
} 

void SetProgramName(const char* argv0) { 
    Argv0 = argv0;
}