{"action":"created","issue":{"url":"https://api.github.com/repos/ladislav-zezula/StormLib/issues/52","labels_url":"https://api.github.com/repos/ladislav-zezula/StormLib/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/ladislav-zezula/StormLib/issues/52/comments","events_url":"https://api.github.com/repos/ladislav-zezula/StormLib/issues/52/events","html_url":"https://github.com/ladislav-zezula/StormLib/issues/52","id":100183933,"number":52,"title":"SFileAddFileEx ERROR_FILE_NOT_FOUND","user":{"login":"PurgeGit","id":5185092,"avatar_url":"https://avatars.githubusercontent.com/u/5185092?v=3","gravatar_id":"","url":"https://api.github.com/users/PurgeGit","html_url":"https://github.com/PurgeGit","followers_url":"https://api.github.com/users/PurgeGit/followers","following_url":"https://api.github.com/users/PurgeGit/following{/other_user}","gists_url":"https://api.github.com/users/PurgeGit/gists{/gist_id}","starred_url":"https://api.github.com/users/PurgeGit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PurgeGit/subscriptions","organizations_url":"https://api.github.com/users/PurgeGit/orgs","repos_url":"https://api.github.com/users/PurgeGit/repos","events_url":"https://api.github.com/users/PurgeGit/events{/privacy}","received_events_url":"https://api.github.com/users/PurgeGit/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-10T22:36:22Z","updated_at":"2015-08-11T05:35:44Z","closed_at":"2015-08-11T05:33:09Z","body":"I was trying to use SFileAddFileEx(...) to add a file to my map. Even though SFileAddFileEx returns true (which should imply that GetLastError() == ERROR_SUCCESS), GetLastError() gives an error code of 2 (which on Mac/Linux is ERROR_FILE_NOT_FOUND).\r\n\r\n* I opened the archive as BASE_PROVIDER_FILE \r\n* I tried different flags for SFileAddFileEx. I'm currently using MPQ_FILE_REPLACEEXISTING, but I tested it with 0 and it still gives that error code.\r\n* The file I'm adding exists on my hard drive, and it is successfully added to the mpq. It is listed if I use SFileFind.\r\n\r\nI'm pretty lost. I can always just use SetLastError(0) after adding the file (and things seem to work okay), but that probably isn't the way to approach it. Does anyone else get this?\r\n\r\nHere is the relevant code if anyone is interested:\r\n``` Objective-C\r\n-(BOOL)addFile:(NSString*)file archivePath:(NSString*)path flags:(unsigned int)flags compression:(unsigned int)compression error:(NSError **)errorPtr {\r\n    const char *fileName = [file UTF8String];\r\n    const char *archivedName = [path UTF8String];\r\n    \r\n    if (!SFileAddFileEx(_archive, fileName, archivedName, flags, compression, compression)) {\r\n        *errorPtr = [MPQ getError];\r\n        return NO;\r\n    }\r\n    //if (GetLastError() == ERROR_FILE_NOT_FOUND) {\r\n    //    SetLastError(0);\r\n    //}\r\n    *errorPtr = nil;\r\n    return YES;\r\n}\r\n```\r\n``` Objective-C\r\nNSString *fileToAdd = @\"/Users/j/Downloads/Warcraft III Stuff/test.j\";\r\n    unsigned int flags = MPQ_FILE_REPLACEEXISTING;\r\n    [mpq addFile:fileToAdd archivePath:@\"test.j\" flags:flags compression:MPQ_COMPRESSION_ZLIB error:&error];\r\n    if (error != nil) { // error is nil\r\n        NSLog(@\"Add file fail.\");\r\n        [ViewController alert:error];\r\n        [mpq close:&error];\r\n        return;\r\n    }\r\n    NSLog(@\"%d\", GetLastError()); // prints '2'\r\n```\r\n\r\nThanks for any and all help. Chances are that this is some silly mistake on my end, but I can't seem to resolve it."},"comment":{"url":"https://api.github.com/repos/ladislav-zezula/StormLib/issues/comments/129711104","html_url":"https://github.com/ladislav-zezula/StormLib/issues/52#issuecomment-129711104","issue_url":"https://api.github.com/repos/ladislav-zezula/StormLib/issues/52","id":129711104,"user":{"login":"PurgeGit","id":5185092,"avatar_url":"https://avatars.githubusercontent.com/u/5185092?v=3","gravatar_id":"","url":"https://api.github.com/users/PurgeGit","html_url":"https://github.com/PurgeGit","followers_url":"https://api.github.com/users/PurgeGit/followers","following_url":"https://api.github.com/users/PurgeGit/following{/other_user}","gists_url":"https://api.github.com/users/PurgeGit/gists{/gist_id}","starred_url":"https://api.github.com/users/PurgeGit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PurgeGit/subscriptions","organizations_url":"https://api.github.com/users/PurgeGit/orgs","repos_url":"https://api.github.com/users/PurgeGit/repos","events_url":"https://api.github.com/users/PurgeGit/events{/privacy}","received_events_url":"https://api.github.com/users/PurgeGit/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T05:35:43Z","updated_at":"2015-08-11T05:35:43Z","body":"That makes sense. Thank you!"}}