src/misc.cpp

changeset 10
bc1414343e19
parent 8
e8f645d9f28f
child 13
9bdddd2ccde6
equal deleted inserted replaced
9:f9893eea978b 10:bc1414343e19
1 #include "misc.h" 1 #include "misc.h"
2 2
3 uint32 makeByteID( uint8 a, uint8 b, uint8 c, uint8 d ) { 3 uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d) {
4 return a | ( b << 8 ) | ( c << 16 ) | ( d << 24 ); 4 return a | (b << 8) | (c << 16) | (d << 24);
5 } 5 }
6 6
7 // ============================================================================= 7 // =============================================================================
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 str binaryConfigName( str ver ) { 9 str binaryConfigName (str ver) {
10 return fmt( "binaries/%1", ver ); 10 return fmt ("binaries/%1", ver);
11 } 11 }
12 12
13 // ============================================================================= 13 // =============================================================================
14 // ----------------------------------------------------------------------------- 14 // -----------------------------------------------------------------------------
15 str basename( str path ) { 15 list<var> getVersionsList() {
16 long lastpos = path.lastIndexOf( "/" ); 16 QSettings cfg;
17 return cfg.value ("binarynames", list<var>()).toList();
18 }
19
20 // =============================================================================
21 // -----------------------------------------------------------------------------
22 list<var> getReleasesList() {
23 QSettings cfg;
24 return cfg.value ("releasenames", list<var>()).toList();
25 }
26
27 // =============================================================================
28 // -----------------------------------------------------------------------------
29 void addVersion (str name, bool isRelease, str binaryPath) {
30 QSettings cfg;
31 list<var> versions = getVersionsList();
32 versions << var (name);
33 cfg.setValue ("binarynames", versions);
34 cfg.setValue (binaryConfigName (name), binaryPath);
17 35
18 if( lastpos != -1 ) 36 if (isRelease) {
19 return path.mid( lastpos + 1 ); 37 versions = getReleasesList();
38 versions << var (name);
39 cfg.setValue ("releasenames", versions);
40 }
41
42 cfg.sync();
43 }
44
45 // =============================================================================
46 // -----------------------------------------------------------------------------
47 str basename (str path) {
48 long lastpos = path.lastIndexOf ("/");
49
50 if (lastpos != -1)
51 return path.mid (lastpos + 1);
20 52
21 return path; 53 return path;
22 } 54 }

mercurial