wxFileExists returns 在 Mac 中为假
wxFileExists returns false in Mac
我在 Mac 中使用 wxWidgets 与 C++(显然)和 Xcode。
这一行 return 错误,而它应该是正确的。
` if(!wxFileExists(filePicker->GetPath())
{
wxMessageDialog(this, "error").ShowModal();
return;
} `
其中 filePicker 是 wxFilePickerCtrl
。它的价值是:
filepath std::__1::string "/Users/swtsvn/Main/Proj1/Mac/binaries/osx/Debug/wxSampleApp.app"
路径是大写的,没有空格。该文件位于该路径中,因为我使用文件选择器 wxWidget 工具选择了该文件路径。
我搜索了 wxFileExists 在 Mac 上可能 return 错误但在 Windows 上不正确的原因,但在 Google 中找不到。
如果有人知道答案,请告诉我。
根据docs,wxFileExists()
:
Returns true
if the file exists and is a plain file.
因此,目录 return 是错误的。 Mac 应用程序包,例如您的 wxSampleApp.app,是目录。在这种情况下,它 return false 是函数的故意行为。
您可能会改用 wxFileExists(path) || wxDirExists(path)
,尽管那样效率会有些低。
我在 Mac 中使用 wxWidgets 与 C++(显然)和 Xcode。
这一行 return 错误,而它应该是正确的。
` if(!wxFileExists(filePicker->GetPath())
{
wxMessageDialog(this, "error").ShowModal();
return;
} `
其中 filePicker 是 wxFilePickerCtrl
。它的价值是:
filepath std::__1::string "/Users/swtsvn/Main/Proj1/Mac/binaries/osx/Debug/wxSampleApp.app"
路径是大写的,没有空格。该文件位于该路径中,因为我使用文件选择器 wxWidget 工具选择了该文件路径。
我搜索了 wxFileExists 在 Mac 上可能 return 错误但在 Windows 上不正确的原因,但在 Google 中找不到。
如果有人知道答案,请告诉我。
根据docs,wxFileExists()
:
Returns
true
if the file exists and is a plain file.
因此,目录 return 是错误的。 Mac 应用程序包,例如您的 wxSampleApp.app,是目录。在这种情况下,它 return false 是函数的故意行为。
您可能会改用 wxFileExists(path) || wxDirExists(path)
,尽管那样效率会有些低。