MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / _AndroidGetTxtFileArgs

Function _AndroidGetTxtFileArgs

engine/source/platformAndroid/main.cpp:104–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104static void _AndroidGetTxtFileArgs(int &argc, char** argv, int maxargc)
105{
106 argc = 0;
107
108 const U32 kMaxTextLen = 2048;
109
110 U32 textLen;
111
112 char* text = new char[kMaxTextLen];
113
114 // Open the file, kick out if we can't
115 File cmdfile;
116
117 File::Status err = cmdfile.open("AndroidCmdLine.txt", cmdfile.Read);
118
119 // Re-organise function to handle memory deletion better
120 if (err == File::Ok)
121 {
122 // read in the first kMaxTextLen bytes, kick out if we get errors or no data
123 err = cmdfile.read(kMaxTextLen-1, text, &textLen);
124
125 if (((err == File::Ok || err == File::EOS) || textLen > 0))
126 {
127 // Null terminate
128 text[textLen++] = '\0';
129
130 // Truncate to the 1st line of the file
131 for(int i = 0; i < textLen; i++)
132 {
133 if( text[i] == '\n' || text[i] == '\r' )
134 {
135 text[i] = '\0';
136 textLen = i+1;
137 break;
138 }
139 }
140
141 // Tokenize the args with nulls, save them in argv, count them in argc
142 char* tok;
143
144 for(tok = dStrtok(text, " "); tok && argc < maxargc; tok = dStrtok(NULL, " "))
145 argv[argc++] = tok;
146 }
147 }
148
149 // Close file and delete memory before returning
150 cmdfile.close();
151
152 delete[] text;
153
154 text = NULL;
155}
156

Callers

nothing calls this directly

Calls 4

dStrtokFunction · 0.70
openMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected