"We're not in Kansas anymore, Toto!" - Dorothy
As the owner of a brand-spanking-new Windows CE PPC, I pressed the power button in a state of great anticipation. The screen brightened and my first reaction was..... "Where is everything?" This may seem a bit glib now, but I think most users ( and probably most software developers) are a little surprised by the absence of an "Explorer" style view of the Windows CE file system on the PPC devices. There's a good reason for this, of course: We don't have the extravagant amounts of archival acreage on a CE device that we do on the desktop, and so we need a storage model that takes this into account. Windows CE's overarching data storage structure is the object store, and all its attributes are informed by the biases inherent in RAM based persistent storage.
A couple of important aspects of the CE file system :
- All files are stored in compressed format
- File system organization is simplified
On the brighter side, while your first glimpse of the PPC shell may leave you a bit at sea, the HPC looks and behaves so much like the Windows desktop that neither you nor your application users will have any difficulty figuring out how to navigate to files and applications. The key point here is that there are slight differences between the classes of CE devices and fairly significant differences between CE and the desktop when it comes to how files are organized. In practice this means that your applications must be aware of where files "land" when they are dropped onto the CE device.
One of the two porting challenges you'll face with respect to file handling is sorting out where files are on a specific device. The second file handling hurdle you'll need to clear has to do with what is in your application's support files. You may well spend as much time and effort preparing your application data for porting to CE as your application's source code. Here's why: All control text, strings, pathnames, and textual function parameters must be in Unicode under CE. Chances are, you'll need to translate desktop application data between the single or multi byte character sets typically used in Win32 applications and Unicode. Another area of potential data incompatibility has to do with some PPC devices limited set of floating point support. You may need to implement workarounds for these, as well.
Where The Files Are
CE's directory structure is dramatically flattened, consisting mainly of a small number of "standard directories" at the root of the file system. Though it is possible to create deeply nested directory structures like those on the desktop, it is not a good idea. In order to use the CE file storage layout as efficiently as possible, you should strive to locate your application files in the "default locations".
As far as file handling is concerned, you can open, close and access CE files using the Win32 file routines, but there are few significant differences. First, there is no concept of "current directory". To access or create a file, you always use its fully qualified pathname. Also, the "standard directories" on the PPC are fewer in number and somewhat differently named than those on the HPC, so default fully qualified pathnames won't necessarily be the same on all devices. In order to throw light on this issue, we are going to look at the storage layout from two points of view. First, we'll examine the CE Services connection windows on the two types of systems, and then we'll explore an example program that demonstrates the use of the Windows common file dialog on each type of system.
On my HPC ( a Compaq C Series ), I open a connection using Windows CE Services, and click on the name of my device in the Mobile Devices window. Here's the first window I see, and the one most users would drag and drop files into from the desktop Windows Explorer.
Figure 1: The Window HPC Users See When They Open A CE Services Connection From The Desktop Computer
When I drag files into this window on my desktop computer, they end up in the directory
This first "Connection Window" has the name of my device as its caption, and doesn't really represent the storage structure of the device at all. Its really just a snapshot of what ever is "on the desktop" of the HPC. To see storage structure, we need to tap the "My Handheld PC" icon.
Opening the My Handheld PC Windows CE Services depicts the HPC root directory.
Figure 2: HPC Root Directories
Notice the window caption in Figure 2 "My Handheld PC". This name has more or less the same significance as "Desktop" on a Windows 9x or NT system. It looks as if
\My Handheld PC
is a top level directory, but don't be misled by this. Here's how the fully qualified pathname for a file named "test.txt" in the "My Documents" directory would look on this HPC device:
Notice two things about this path: First, there is no drive letter, and second, the directory
is at the root of the file system.
In a PPC "Connection Window", things are laid out a bit differently. Opening a CE Services Window for my Cassiopea, the directory layout is simplified, and is presented like this:
Figure 3: The PPC's CE Services Connection Window
If I drag files from the Windows 9x or NT desktop to this window, the filenames show up at the bottom of the list of folders in the PPC connection window. However, document files actually end up in the \My Documents directory. If you experiment with the CE Services Connection windows for your own device they may have a slightly different appearance than these. The point of these specific comparisons, however, stands: There are some differences between the directory structure and default locations of files on the PPC and the HPC.
The reason that this is important is that the Windows common file dialog is implemented differently on the PPC than on the HPC. The PPC's dialog is much less flexible in terms of allowing the user to browse to the location of the file they wish to open than that of the HPC. In order to correctly initialize the common file dialog, you must be aware of where the files are.
Porting Tip: Make sure that the files you want users to open with the common File Open dialog are in the \My Documents directory on the PPC, or the user won't be able to find them.
In the next installment, we'll begin examining the FileOpen example, which demonstrates the differences between standard directories on the PPC and HPC, how to initialize and use the common file dialog on each of these platforms and the action of various file permissions when opening files.
About the Author
Nancy Nicolaisen is a software engineer who has designed and implemented highly modular Windows CE products that include features such as full remote diagnostics, CE-side data compression, dynamically constructed user interface, automatic screen size detection, entry time data validation.
In addition to writing for Developer.com, she has written several books, including Making Win 32 Applications Mobile.
# # #