Lines Matching refs:ctx
69 WIN32_FIND_DATA ctx;
74 const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
76 if (ctx == NULL || directory == NULL) {
82 if (*ctx == NULL) {
90 *ctx = malloc(sizeof(**ctx));
91 if (*ctx == NULL) {
95 memset(*ctx, 0, sizeof(**ctx));
126 free(*ctx);
127 *ctx = NULL;
152 (*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx);
166 (*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx);
169 if ((*ctx)->handle == INVALID_HANDLE_VALUE) {
170 free(*ctx);
171 *ctx = NULL;
176 if (FindNextFile((*ctx)->handle, &(*ctx)->ctx) == FALSE) {
181 TCHAR *wdir = (*ctx)->ctx.cFileName;
184 while (wdir[len_0] && len_0 < (sizeof((*ctx)->entry_name) - 1))
190 (*ctx)->entry_name,
191 sizeof((*ctx)->entry_name), NULL, 0))
194 (*ctx)->entry_name[index] = (char)wdir[index];
196 strncpy((*ctx)->entry_name, (const char *)(*ctx)->ctx.cFileName,
197 sizeof((*ctx)->entry_name) - 1);
199 (*ctx)->entry_name[sizeof((*ctx)->entry_name) - 1] = '\0';
201 return (*ctx)->entry_name;
204 int LP_find_file_end(LP_DIR_CTX **ctx)
206 if (ctx != NULL && *ctx != NULL) {
207 FindClose((*ctx)->handle);
208 free(*ctx);
209 *ctx = NULL;