Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: CBXE8 - Cannot FileOpen /init.rc in Android ?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Oct 7, 2015 9:03 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
CBXE8 - Cannot FileOpen /init.rc in Android ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 12:42 AM
Embarcadero® C++Builder XE8 Version 22.0.19027.8951 and Indy 10.
Window 10 Pro x64
Android 4.1.2

QUESTIONS:

1. I have tried the following instructions to open file "./init.rc" but failed to do so.

fh = (int)FileOpen( UnicodeString( L"./init.rc" ), fmOpenReadWrite|fmShareDenyNone );
if( fh == INVALID_HANDLE_VALUE )
{
return -1;
}

OR

fh = (int)FileOpen( UnicodeString( L"./init.rc" ), fmOpenRead|fmShareDenyNone );
if( fh == INVALID_HANDLE_VALUE )
{
return -1;
}

Does FIleOpen() or the Application itself required elevated Administrator rights in Android ?

Please advise.
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
Re: CBXE8 - Cannot FileOpen /init.rc in Android ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 12:58 AM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
...found my mistake, this instruction works:

fh = (int)FileOpen( UnicodeString( L"./init.rc" ), fmOpenRead|fmShareDenyNone );
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: CBXE8 - Cannot FileOpen /init.rc in Android ? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 9:03 AM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
GAI wrote:

fh = (int)FileOpen( UnicodeString( L"./init.rc" ),
fmOpenRead|fmShareDenyNone );

You don't need the explicit UnicodeString or integer casts:

fh = FileOpen( L"./init.rc", fmOpenRead|fmShareDenyNone );


Or even:

fh = FileOpen( _D("./init.rc"), fmOpenRead|fmShareDenyNone );


Does FIleOpen() or the Application itself required elevated
Administrator rights in Android ?

It depends on where the file is located. But in this case, no. On the other
hand, you probably should be using something like TPath::GetHomeDir() instead
of "./".

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02