remove igit and libiconv2.dll at install script
[TortoiseGit.git] / src / Git / gittype.h
bloba66f4b66dfac5cb0d57e3c2f2069c9d29e9222cd
1 #pragma once
3 enum
5 GIT_SUCCESS=0,
6 GIT_ERROR_OPEN_PIP,
7 GIT_ERROR_CREATE_PROCESS,
8 GIT_ERROR_GET_EXIT_CODE
9 };
11 extern BOOL g_IsWingitDllload;
13 class CGitByteArray:public std::vector<BYTE>
15 public:
16 int find(BYTE data,int start=0)
18 for(int i=start;i<size();i++)
19 if( at(i) == data )
20 return i;
21 return -1;
23 int findNextString(int start=0)
25 int pos=start;
28 pos=find(0,pos);
29 if(pos >= 0)
30 pos++;
31 else
32 break;
34 if( pos >= size())
35 return -1;
37 }while(at(pos)==0);
39 return pos;
41 int findData(const BYTE* dataToFind, size_t dataSize, int start=0)
43 //Pre checks
44 if(empty())
45 return -1;
46 if(dataSize==0)
47 return 0;
48 if(dataSize>size()-start)
49 return -1;//Data to find is greater then data to search in. No match
51 //Initialize
52 const BYTE* pos=&*(begin()+start);
53 const BYTE* dataEnd=&*(begin()+(size()-dataSize) );++dataEnd;//Set end one step after last place to search
54 if(pos>=dataEnd)
55 return -1;//Started over end. Return not found
56 if(dataSize==0)
57 return start;//No search data. Return current position
58 BYTE firstByte=dataToFind[0];
59 while(pos<dataEnd)
61 //memchr for first character
62 const BYTE* found=(const BYTE*)memchr(pos,firstByte,dataEnd-pos);
63 if(found==NULL)
64 return -1;//Not found
65 //check rest of characters
66 if(memcmp(found,dataToFind,dataSize)==0)
67 return found-&*begin();//Match. Return position.
68 //No match. Set position on next byte and continue search
69 pos=found+1;
71 return -1;
73 int append( std::vector<BYTE> &v,int start=0,int end=-1)
75 if(end<0)
76 end=v.size();
77 for(int i=start;i<end;i++)
78 this->push_back(v[i]);
79 return 0;
81 int append(const BYTE* data, size_t dataSize)
83 size_t oldsize=size();
84 resize(oldsize+dataSize);
85 memcpy(&*(begin()+oldsize),data,dataSize);
86 return 0;
89 typedef std::vector<CString> STRING_VECTOR;
90 typedef std::map<CString, STRING_VECTOR> MAP_HASH_NAME;
91 typedef CGitByteArray BYTE_VECTOR;