Platform Builder: Using Dat Files to Initialize the File System

<< Platform Builder: Using Bib Files to add files to a Windows CE OS Image | Home | Platform Builder: Build error “Bad database entry:” >>

If you haven’t noticed already, all of the files that you put in the Windows CE OS image end up in the \Windows folder. There is nothing that you can do about that, but you can creates other folders and copy files into those folders using DAT files.

DAT files can be somewhat of a mystery because most BSPs don’t do anything with them and the default OSDesigns don’t include anything in the project.dat file. But, the DAT files in the Public folders do include plenty of examples and Platform Builder Help does a good job of documenting the files.

Before going on, this word of caution: the only thing that you can do with files in DAT files is copy them. This means that you will be using extra RAM in your system to hold the copy of the file. So the cost of the RAM use must be taken into consideration.   For executables, you can include a shortcut in the OS that you copy which gives the same look and feel, but uses less RAM.

The commands, or file parameters, in DAT files are:

·         root, which designates the root folder

·         Directory(“”), which is used to both designate a folder and to create a new folder

·         Permdir(“”), which is used to create a new folder that cannot be deleted by the user

·         File(“”, “”), which is used to copy a file

Create a folder

You can use DAT files to create a folder, or folder tree. This is exactly what the DAT files in the Public folders do to create the directory structure that you see when you boot your system.

Example of creating \MyFolder\SubFolder using Project.dat:

root:-Directory("MyFolder")

Directory("\MyFolder "):-Permdir("SubFolder ")

Which does the following:

1.       Creates a folder named MyFolder in the root of the file system.

2.       Creates a folder named SubFolder in \MyFolder which cannot be deleted

It is a little interesting that Directory is used in two ways; one to create a directory, and the other to specify a folder in which the new directory will be created.

Copy a File to a Folder

You can also use DAT files to copy files from the \Windows folder to one or the newly created folders.

Example of copying MyApp.lnk to \MyFolder\SubFolder:

Directory("\MyFolder \ SubFolder "):-File("MyApp.lnk", "\Windows\ MyApp.lnk")

Which copies \Windows\MyApp.lnk to \MyFolder\SubFolder\MyApp.lnk But what if you want to rename the file?

Directory("\MyFolder \ SubFolder "):-File("MyNewName.lnk", "\Windows\ MyApp.lnk")

Which renames MyApp.lnk to MyNewName.lnk when it copies it to \MyFolder\MySubfolder.

 

Copyright © 2008 – Bruce Eitman

All Rights Reserved

Tuesday, June 17, 2008 10:29 PM

This article is part of the GWB Archives. Original Author: Bruce Eitman

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.