当文件明确存在时,哪些权限可以使CreateFileA返回ERROR_FILE_NOT_FOUND?

时间:2015-12-22 03:17:14

标签: c++ boost

这里有一点背景:

1)我使用boost :: interprocess :: shared_memory_object作为两个进程之间的消息传递接口。

2)在“服务器”端创建一个文件。在“客户端”侧打开并读取文件。该文件是从C:\ ProgramData \ boost_interprocess。

创建和读取的

3)使用QProcess :: startDetached()

从“服务器”端启动“客户端”端

4)当应用程序安装在本地驱动器(C :)上时,一切正常

5)当应用程序安装在网络驱动器(N :)上时,“客户端”端在尝试读取文件时报告ERROR_FILE_NOT_FOUND,即使“服务器”端明确创建了该文件。

Server side code (with logging statements):
 logFile << "  Attempting to create: " << shmfile.c_str() << "\n";
 m_handle = ipcdetail::create_new_file(shmfile.c_str(), mode, perm, true);
 logFile << "  Create finished.  File handle is: " << m_handle << "\n";
 if (boost::filesystem::exists(shmfile.c_str(), errorCode))
     logFile << "  Created file and it exists\n";
 else
     logFile << "  Attempted to create file and it does not exist.  Error code is: " << errorCode << "\n";

Client Side Code (with logging statements):
 if (boost::filesystem::exists(shmfile.c_str(), errorCode))
     logFile << "  DoOpen - File exists according to boost\n";
 else
     logFile << "  DoOpen - File doesn't exist.  Error code is: " << errorCode << "\n";
 logFile << "  Attempting to open: " << shmfile.c_str() << "\n";
 m_handle = ipcdetail::open_existing_file(shmfile.c_str(), mode, true, &logFile);
 logFile << "  Open finished.  File handle is: " << m_handle << "\n";

在上面的代码中,ipcdetail :: create_new_file()和ipcdetail :: open_existing_file()最终调用最低级别的CreateFileA()。

显示错误的示例日志文件如下所示:

从服务器端:

  • 尝试创建: C:\ ProgramData / boost_interprocess / 20151221093212.125599 / {c94a1cac-d0e2-4f33-bc0e-3d26e6c19dd0}
  • 创建完成。文件句柄为:0000000000000CF4
  • 创建文件和 它存在

从客户端:

  • DoOpen文件不存在。错误代码是:system:2
  • 正在尝试打开:C:\ ProgramData / boost_interprocess / 20151221093212.125599 / {c94a1cac-d0e2-4f33-bc0e-3d26e6c19dd0}
  • 打开完成。文件句柄为:FFFFFFFFFFFFFFFF

从代码和日志中可以看出,服务器端成功创建了文件,boost :: filesystem :: exists()调用显示该文件存在。在客户端,同样的boost :: filesystem :: exists()调用报告该文件不存在。最后我们通过ipcdetail :: open_existing_file()向下报告CreateFileA,它报告了同样的问题。

这可能就像权限问题一样简单吗?如果是这样,哪些权限可能导致文件甚至无法找到?

0 个答案:

没有答案