{"action":"closed","issue":{"url":"https://api.github.com/repos/dbartolini/crown/issues/76","repository_url":"https://api.github.com/repos/dbartolini/crown","labels_url":"https://api.github.com/repos/dbartolini/crown/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/dbartolini/crown/issues/76/comments","events_url":"https://api.github.com/repos/dbartolini/crown/issues/76/events","html_url":"https://github.com/dbartolini/crown/issues/76","id":298706353,"number":76,"title":"Windows: CreateDirectory fails due to empty data_dir","user":{"login":"robhshu","id":1644232,"avatar_url":"https://avatars1.githubusercontent.com/u/1644232?v=4","gravatar_id":"","url":"https://api.github.com/users/robhshu","html_url":"https://github.com/robhshu","followers_url":"https://api.github.com/users/robhshu/followers","following_url":"https://api.github.com/users/robhshu/following{/other_user}","gists_url":"https://api.github.com/users/robhshu/gists{/gist_id}","starred_url":"https://api.github.com/users/robhshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robhshu/subscriptions","organizations_url":"https://api.github.com/users/robhshu/orgs","repos_url":"https://api.github.com/users/robhshu/repos","events_url":"https://api.github.com/users/robhshu/events{/privacy}","received_events_url":"https://api.github.com/users/robhshu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-20T18:48:25Z","updated_at":"2018-02-20T19:26:22Z","closed_at":"2018-02-20T19:26:22Z","author_association":"NONE","body":"I've downloaded and built crown on Windows and immediately hit this assert:\r\n\r\n> \r\n> Assertion failed: err != 0\r\n>     In: ..\\..\\..\\src\\core\\os.cpp:178\r\n>     CreateDirectory: GetLastError = 3\r\n> Stacktrace:\r\n>     [ 1] crown::error::abort in c:\\users\\rhs\\github\\crown\\src\\core\\error\\error.cpp:26\r\n>     [ 2] crown::error::abort in c:\\users\\rhs\\github\\crown\\src\\core\\error\\error.cpp:35\r\n>     [ 3] crown::os::create_directory in c:\\users\\rhs\\github\\crown\\src\\core\\os.cpp:178\r\n>     [ 4] crown::FilesystemDisk::create_directory in c:\\users\\rhs\\github\\crown\\src\\core\\filesystem\\filesystem_disk.cpp:326\r\n>     [ 5] crown::Device::run in c:\\users\\rhs\\github\\crown\\src\\device\\device.cpp:359\r\n>     [ 6] crown::run in c:\\users\\rhs\\github\\crown\\src\\device\\device.cpp:760\r\n>     [ 7] crown::func in c:\\users\\rhs\\github\\crown\\src\\device\\main_windows.cpp:337\r\n>     [ 8] crown::Thread::run in c:\\users\\rhs\\github\\crown\\src\\core\\thread\\thread.cpp:105\r\n>     [ 9] crown::thread_proc in c:\\users\\rhs\\github\\crown\\src\\core\\thread\\thread.cpp:21\r\n\r\nWhat seems to be happening is `Device::run` is looking for the data directory, and as it isn't set is returning `\"\"` instead of `nullptr` - so instead of falling back on `os::getcwd` to get the current directory - it uses an empty string, which goes through this logic:\r\n```cpp\r\n\tconst char* data_dir = _device_options._data_dir.c_str(); // returns \"\", not nullptr\r\n\tif (!data_dir) // doesn't hit\r\n\t{\r\n\t\tchar buf[1024];\r\n\t\tdata_dir = os::getcwd(buf, sizeof(buf));\r\n\t}\r\n\t_data_filesystem = CE_NEW(_allocator, FilesystemDisk)(default_allocator());\r\n\t((FilesystemDisk*)_data_filesystem)->set_prefix(data_dir);\r\n\tif (!_data_filesystem->exists(data_dir)) // \"\" does not exist, so this condition is met\r\n\t\t_data_filesystem->create_directory(data_dir); // attempts to create a new directory with \"\"\r\n```\r\n\r\nOne fix could be to check the length:\r\n\r\n```cpp\r\n_device_options._data_dir.length() > 0\r\n```"}}
{"actor":{"display_login":"dbartolini"}}