Can't read Files in Chromium (CPP) using fstream and ifstream

104 views
Skip to first unread message

Akash Agrawall

unread,
Mar 19, 2017, 1:56:11 AM3/19/17
to Chromium-dev
Hello all,

I am trying to read file content in Chromium but am getting blank text when I log the value. Is there any permission issue regarding this ?
I have tried reading file both using std::fstream and std::ifstream.

However, I am able to write to the file using std::ofstream successfully.

Please mention if I am missing anything here.

Thanks and Regards,
Akash Agrawall,
Masters Student,
IIIT Hyderabad

PhistucK

unread,
Mar 19, 2017, 2:50:40 AM3/19/17
to Akash Agrawall, Chromium-dev
Are you doing this within the code of the renderer (anything within /content, or within /third_party/WebKit, for example), or the browser?
The former fails due to the sandbox (it protects renderers from affecting the rest of the system), I am not sure about the latter.

In what file are you adding it?


PhistucK

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/b3740517-cd4d-4e9f-9510-7fbbf5530e91%40chromium.org.

Akash Agrawall

unread,
Mar 19, 2017, 3:03:33 AM3/19/17
to PhistucK, Chromium-dev
Ohh I see. I am adding it here:
/src/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
which would fail due to sandbox reasons.

Can you mention another way to read from file, or any other easy way to share data across files using some data structure ?

On Sun, Mar 19, 2017 at 12:19 PM PhistucK <phis...@gmail.com> wrote:
Are you doing this within the code of the renderer (anything within /content, or within /third_party/WebKit, for example), or the browser?
The former fails due to the sandbox (it protects renderers from affecting the rest of the system), I am not sure about the latter.

In what file are you adding it?


PhistucK

On Sun, Mar 19, 2017 at 7:56 AM, Akash Agrawall <akashagr...@gmail.com> wrote:
Hello all,

I am trying to read file content in Chromium but am getting blank text when I log the value. Is there any permission issue regarding this ?
I have tried reading file both using std::fstream and std::ifstream.

However, I am able to write to the file using std::ofstream successfully.

Please mention if I am missing anything here.

Thanks and Regards,
Akash Agrawall,
Masters Student,
IIIT Hyderabad

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

PhistucK

unread,
Mar 19, 2017, 3:27:25 AM3/19/17
to Akash Agrawall, Chromium-dev
I think you need to send a message to the browser, which would open the file itself and return the content of the file as a response.
You should probably leverage Mojo.

I am not familiar with the code enough to tell you how this is done, though. cs.chromium.org as well as dev.chromium.org (example - https://www.chromium.org/developers/design-documents/mojo/mojo-migration-guide) might be good resources for helping yourself.


PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

Matthew Menke

unread,
Mar 19, 2017, 10:35:17 PM3/19/17
to Chromium-dev, akash.ag...@gmail.com
Somewhat unrelated comment...but should ofstream be working from the renderer process?  That seems like it could cause problems.


PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Akash Agrawall

unread,
Mar 20, 2017, 1:13:07 AM3/20/17
to Matthew Menke, Chromium-dev
Nope, it is not working from renderer process.
It returns blank content from a non-empty file. I experienced the same case when I ran ifstream on a file, not present in file system. 

Hence, it is secure I think.
Reply all
Reply to author
Forward
0 new messages