mimir
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Это очень похоже на ошибку. У меня это значение выдаеться при отсутствии файла. Цитата: The GetFileAttributes function retrieves a set of FAT file system attributes for a specified file or directory ***** If the function succeeds, the return value contains the attributes of the specified file or directory. If the function fails, the return value is INVALID_FILE_ATTRIBUTES. | Цитата: #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) | Добавлено: вроде это то что нужно. У меня стоит только FAT пожтому не могу тестировать. Цитата: The GetFileAttributes function retrieves a set of FAT file system attribute information. GetFileAttributesEx can obtain other sets of file or directory attribute information. Currently, GetFileAttributesEx retrieves a set of standard attributes that is a superset of the FAT file system attribute information. | Добавлено: Цитата: void push_lasterr(lua_State *L, LPTSTR lpszFunction) { LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR)); StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf), TEXT("%s failed with error %d: %s"), lpszFunction, dw, lpMsgBuf); lua_pushstring(L,(LPTSTR)lpDisplayBuf); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); } static int l_getfileattr (lua_State *L) { const char*FN = luaL_checkstring(L,-1); WIN32_FILE_ATTRIBUTE_DATA fad; if(0==GetFileAttributesEx(FN,GetFileExInfoStandard ,&fad)){ lua_pushnil(L); push_lasterr(L,"\"getfileattr\""); return 2; } lua_pushnumber(L, fad.dwFileAttributes); return 1; } static int l_setfileattr (lua_State *L) { const char *FN = luaL_checkstring(L,-2); DWORD attr = luaL_checkint(L,-1); if(0 == SetFileAttributes(FN, attr)){ lua_pushnil(L); push_lasterr(L,"\"setfileattr\""); return 2; } lua_pushinteger(L, 1); return 1; } | |