c++linuxremote-debuggingtargetingremote-development

C++ stat() function not finding remote file


I'm using Visual Studio and I'm connected to my Linux machine using remote development (https://learn.microsoft.com/en-us/cpp/linux/connect-to-your-remote-linux-computer?view=msvc-170). I'm trying to call the stat() function to find if a file exists, but it can never find it. I believe this is because; in the documentation for stat(), it says

If you are accessing a remote file through the Network File System, update operations to file permissions at the server are not reflected at the client until updates to data that is stored locally by the Network File System take place. (Several options on the Add Mounted File System (ADDMFS) command determine the time between refresh operations of local data.) Access to a remote file may also fail due to different mappings of user IDs (UID) or group IDs (GID) on the local and remote systems.

Is there a way to fix this? I'm wondering if there is a way to specify a remote file path though visual studio or something?


Solution

  • If your program is being built on the remote machine, presumably it is also being run there (unless you are also doing cross-compilation, which is a very different thing). You therefore do not need any special syntax to refer to files on that machine (which is remote for your editor but not your process).

    You still have to worry about the usual questions like case-sensitivity and your current working directory (for the process, not the editor); the bit in the documentation you found is about network filesystems mounted by the target machine.