Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Nov 20, 2019 9:31 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Declare Function
PostPosted: Wed Jan 30, 2013 5:52 pm 
Offline

Joined: Sat Oct 29, 2005 6:06 pm
Posts: 330
Location: Rochester, NY
I have a function that I am using for trying to open the disk on my mbp but it keeps returning nothing like the call is not working right or something. I do something similar on Windows using an API call for CreateFile and that does the same behavior as the mac side. The reasoning behind the API call stuff is because I need to access the disk with extra params that the RB framework does not offer such as File Share etc.

I am using RB 2009R2.1 for this project.

The code I have is below. Any suggestions would be appreciated.


declare function open lib SystemLib (path as CString, flags as int32) As int32
//Soft Declare Function __error Lib systemlib () as Ptr
soft declare function libcErrorCode lib "System.framework" alias "__error" () as Ptr
Soft Declare Function strerror Lib "System.framework" (errcode as Integer) as Ptr

const kReadOnly = 0
const kReadWrite = 2

//Open the disk.
dim iResult as int32
iResult = open( "/dev/"+ volume, kReadOnly )

if iResult = -1 then
return 0
end
return iResult


Thanks.

_________________
Tom Russell
Using RB2009R3 on Windows XP/7, RB2010R1 on Mac OSX
MBP 15.4" 2.53ghz 4gig Ram 500HDD
iMac 24" 2.4 ghz 4gig Ram 500HDD


Top
 Profile  
Reply with quote  
 Post subject: Re: Declare Function
PostPosted: Thu Jan 31, 2013 1:13 am 
Offline
User avatar

Joined: Thu Feb 16, 2006 10:04 pm
Posts: 262
First of all, you're not being very precise regarding the information you posted, no need to include functions your not asking about and we have no idea the string value of 'volume', but here's my guess ... :-)

I'm assuming when you say it 'keeps running' that you are getting a -1 as a return result. First of all read the man pages in the terminal type, 'man open'. You are most likely getting the -1 because of the path string you are passing in 'volume'. It has to be the correct format for the function to operate on. For example, this code will break with -1;
Declare Function open lib "System" (path as CString, flags as int32) As int32
const kReadOnly = 0
//Open the disk.
dim iResult as int32
iResult = open( "/Applications/Real\ Studio\ 2012\ Release\ 2.1/Cocoa\ Beta\ Information.pdf", kReadOnly)
if iResult = -1 then
Break
else
Break
End


But this one will break as successful, with a value of 8 in my case,

Declare Function open lib "System" (path as CString, flags as int32) As int32
const kReadOnly = 0
//Open the disk.
dim iResult as int32
iResult = open( "/Applications/Real Studio 2012 Release 2.1/Cocoa Beta Information.pdf", kReadOnly)
if iResult = -1 then
Break
else
Break
End


I got the first path by dropping the file on to my terminal window, it's formatted in a way that the RB function does not understand.

_________________
Thomas C.
Real Studio Blog
http://bigdaddysurf.com/blog/

https://itunes.apple.com/us/app/maui-dragstrip-2013/id604516033?mt=8
https://itunes.apple.com/us/book/how-to-waterstart/id576214730?mt=11


Top
 Profile  
Reply with quote  
 Post subject: Re: Declare Function
PostPosted: Thu Jan 31, 2013 5:29 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
You can't open raw disk without permissions...

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Declare Function
PostPosted: Thu Jan 31, 2013 10:00 am 
Offline

Joined: Sat Oct 29, 2005 6:06 pm
Posts: 330
Location: Rochester, NY
Is there a way to set permissions on all platforms for this to work?

Thanks.

_________________
Tom Russell
Using RB2009R3 on Windows XP/7, RB2010R1 on Mac OSX
MBP 15.4" 2.53ghz 4gig Ram 500HDD
iMac 24" 2.4 ghz 4gig Ram 500HDD


Top
 Profile  
Reply with quote  
 Post subject: Re: Declare Function
PostPosted: Thu Jan 31, 2013 10:08 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Root user can do anything, even format disk.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Declare Function
PostPosted: Thu Jan 31, 2013 10:16 am 
Offline

Joined: Sat Oct 29, 2005 6:06 pm
Posts: 330
Location: Rochester, NY
MonkeybreadSoftware wrote:
Root user can do anything, even format disk.

Greetings
Christian



Yea I am aware of that but how does one set the permissions programmatically?

_________________
Tom Russell
Using RB2009R3 on Windows XP/7, RB2010R1 on Mac OSX
MBP 15.4" 2.53ghz 4gig Ram 500HDD
iMac 24" 2.4 ghz 4gig Ram 500HDD


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group