Identify a mounted volume as a CD/DVD on osx - c++

When you mount anything on osx it shows up under /Volumes/mountname
Is there any way, using the commandline or C/C++ to identify the volume as a CD/DVD rom?
My current best idea goes something like this.
df | grep mountname
to get the /dev/diskNsM path
and then
drutil | grep /dev/diskN
to see if the path mounted device is the burner.
This works, but i'm concerned about the case where the CD/DVD is not a burner. Will it still show up in the output of drutil? Do macs even come with a non-burner CD/DVD drive?
Also i would prefer using C,C++ or objective C to do this.
I already use
const char *tmp = '/Volumes/mysterydrive';
statfs(tmp, &m);
if(m.f_flags & MNT_RDONLY)
{
read_only = true;
}
to determine if the volume is readonly,
but i cannot see if this or any related call can distinguish between a CD/DVD and a readonly mounted volume.
It would only need to work for OSX 10.5 and newer.
Any ideas?
EDIT:
Using
diskutil info /Volumes/mysterydrive
I got the following output if its a CD/DVD
Optical Drive Type: CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-R, DVD-R DL, DVD-RW, DVD+R, DVD+R DL, DVD+RW
Optical Media Type: DVD-R
Optical Media Erasable: No
And that's all i need!
I'll look into using IOKit to do it programmatically later, but this seems to be the quickest way to get it done.

You get the most detailed information from
diskutil info /Volume/foo
In particular see Optical Drive and Optical Media entries which you only get for CD/DVDs so it is quite reliable.
Unfortunately the frameworks that diskutil uses to get all that information are private, so it will be hard to replicate it in C code.
I didn't dig deeper into other options, but since you can get the disk name from statfs it may be in theory possible to use IOKit to check out the device and you'll see IOCDMedia or IODVDMedia class if it is a CD/DVD drive (i.e. if you look for IO*Media class the BSD Name property has the disk name like disk6)

Apple Developer Central has a sample code project called CDROMSample that shows using IOKit routines to access CD-ROM properties. This might give you a start into handling DVDs, as well.

Related

What is the argument for Graphics.set_font from the OCaml Graphics package?

I'm trying to use the Ocaml Graphics package. I want to create a GUI for my chat server application. My code is:
let window = Graphics.open_graph "";
Graphics.set_window_title "caml-chat";
Graphics.set_font "ubuntu";
Graphics.set_text_size 12;
Graphics.draw_string "hello!"
However, Graphics.set_font "ubuntu" does not work. The documentation says that the string argument is system dependent, but I cannot find any more information than that. The only mention I found was in the answers to this question, and it didn't work.
Does anyone know anything else about setting the font? (Or can point me in the direction of a simple graphics library with better documentation?)
Although you didn't specify your system, I will assume that it is Linux (I doubt that Windows has an ubuntu font).
On Linux, the set_font function passes the argument to the X Lib's XLoadFont function. You can use the fc-list or xfontsel utilities to query for the available fonts on your system, or call directly to the XListFonts function.
For example,
fc-list | cut -d: -f2 | sort -u
will give you a list of font families, which you can pass to set_font function. Some lines will have more than one family per line, separated with comman (,). There are many more options, you can specify various styles, sizes, etc. But this is all out of the scope. You can the fontconfig guide to learn more about the font subsystem. For example, [here], at the section "Font Names", you can find the explanation of how the font name is constructed.

What are those folders in SDL-1.2.15

I'm trying to understand source code of SDL-1.2.15, and to find out how it renders stuff on windows. But I can't find where the rendering is happening. I looked inside SDL-1.2.15/src/video folder, and there is a ton of subfolders, and I don't know what any of these stands for. See for yourself.
aalib/ directfb/ ipod/ os2fslib/ quartz/ windib/
ataricommon/ dummy/ maccommon/ photon/ riscos/ windx5/
bwindow/ fbcon/ macdsp/ picogui/ svga/ wscons/
caca/ gapi/ macrom/ ps2gs/ symbian/ x11/
dc/ gem/ nanox/ ps3/ vgl/ xbios/
dga/ ggi/ nds/ qtopia/ wincommon/ Xext/
Is this documented somewhere? This is a pretty popular library, so it probably is documented, right? Right? What's the point of having source code if you can't even understand it, if you can't find functions you are using.
While not all the names are self-explanatory, they contain some hints.
directfb, fbcon (framebuffer console) and X (x11, Xext) are output layers on Linux (unix).
The ones starting with win indicate they are for Windows. More specifically, windib should be about device independent bitmaps (DIBs), dx5 about DirectX 5, and wincommon about some common stuff. Indeed, using grep shows that (only) these folders contain Windows-specific code:
grep -r windows.h src/video/*
[ lists files in the win* folders ]
You could also just compile the package on Windows and see which files were compiled (which folders contain object files)
However, to find out what it actually does, you should rather study the function you're interested in (e.g. SDL_BlitSurface), look at it's implementation, and then look at the implementation of the functions it uses. Start in SDL_video.h (and notice that SDL_BlitSurface is just a define).
You should use some tool to search the code base. Grep or some IDE. Or both.
First of all, why not SDL2?
These are different SDL's video drivers. You can get what driver is used by your program by calling SDL_VideoDriverName. Which driver will be used determined by target platform (e.g. operating system - most drivers are platform-specific), environment variable SDL_VIDEODRIVER, or calling side.

How to find Logical Name for PinPad XFS if it is not mentioned in Manual

I have started XFS implementation of SZZT Pinpad .I am facing an issue with the WFSOpen command Its giving an error “ – 14 “which is mentioned as WFS_ERR_HARDWARE_ERROR in the Manual. Please let us know if we are missing out on any parameter Value for the same .
Also we are unable to find the logical Name for SZZT Pinpad in the Manual . As of now we are using the same name which is been mentioned in the Registry
I've had recently this problem. In my case, it was due to the service provider not being found (more exactly, the SP implementation DLL).
The reason behind, in my case, was that I was using a 64 bits Windows 7. In a 64bits SO, the registry localization is not in HKEY_LOCAL_MACHINE\SOFTWARE\XFS but in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\XFS
BTW, the xfs setup puts a 64bitsregs.reg in C:\xfs (or the directory you selected to install the xfs in)
you can find your logical name or service name from below path for windows xp:
general:
HKEY_LOCAL_MACHINE\SOFTWARE\"AtmVendor"\RSPServer\XFS
in my case:
HKEY_LOCAL_MACHINE\SOFTWARE\BanqIT\RSPServer\XFS

Folder size linux

I need to monitor folders on my linux machine periodically to check whether they are exceeding certain limits.
I have checked stat function call but running stat recursively on all sub folders and files is time consuming and I need to do this for all folders.
Does kernal maintain any datastructures which I can interpret in my program.Or is their any standard api for this.
If you need to enforce limits then use quotas
In case the quota mechanism isn't suitible, then
inotify might be handy:
From wikipedia:
inotify is a Linux kernel subsystem
that acts to extend filesystems to
notice changes to the filesystem, and
report those changes to applications.report those changes to applications.
Type
du -sm directory_name
Will give you the total size of the directory in megabytes recursively.
Type
man du
for help with this command.
You want quotactl:
quotactl -- manipulate filesystem quotas
SYNOPSIS
#include <sys/types.h> /* types needed by quota.h */
#include <sys/quota.h> /* for disk quotas */
Calling stat recursively is the only way to get the current folder size. If you want to continuously monitor the file system, take a look at inotify.
I agree with #Axel. However if you really need to do this in code, you could execute the du shell command via popen:
FILE* pf = popen("du -ch [your folder] | grep total")
Then read the output from the command via the file handle and fgets(...)
Use command du, check this link ...
"How To Check Folder Size"

Displaying CAknInformationNote on device

I am fetching the call-logs, appending them on information note using:
CAknInformationNote* note = new (ELeave) CAknInformationNote;
note->ExecuteLD(callLogs);
I perfectly run on emulator (show all call-logs on note) but nothing shows up when run on the actual device (a Nokia N73). Any ideas?
i think you should use some kind of file logging(you can even use RFile) and see till what point your application executing.i am assuming you dont see a crash/panic on hardware.i doubt if you are able to get the call logs properly first on device.