Windows CE: Adding two files of the same name to two different folders in the file system (Part two of one)
Based on some recent blog comments I wanted to add some additional information to the existing Windows CE: Adding two files of the same name to two different folders in the file system. blog post.
The first comment is that you don't need to copy your files to the flat release directory, although it's common practice to do so - you can use BIB files to copy files from any location on the build machine and rename the files into the \Windows folder on the target image. Take the example below - I have a source file in this folder C:\demo\CE6_Folder_Test\ThirdFox\ThirdFox.txt, I want the file to be called "fox.txt" and mapped to the \Demo\ThirdFox folder on the device.
My totally contrived operating system image contains three versions of the "fox.txt" file, each in different folders - I need to use the BIB file to add the base file to the \Windows folder of my device image - I can then use .DAT files to map the file from the \Windows folder to its final destination, which, in this case will be \Demo\ThirdFox.
The BIB file can be used to grab the original file (called ThirdFox.txt) and add this to the \Windows folder as Fox3.txt (yes, I could have kept the name the same, but that's not the point) - here's how - notice the third line of the FILES section adding fox3.txt.
;
; Copyright (c) 2005 Microsoft Corporation. All rights reserved.
;
;
; NOTE: if any of the .EXE's included in this component are .NETCF
; you will need to move them to the FILES section.
;
MODULES
; Name Path Memory Type
; -------------- --------------------------------------------- -----------
FILES
; Name Path Memory Type
; -------------- --------------------------------------------- -----------
fox1.txt $(_FLATRELEASEDIR)\fox1.txt NK
fox2.txt $(_FLATRELEASEDIR)\fox2.txt NK
fox3.txt C:\demo\CE6_Folder_Test\ThirdFox\ThirdFox.txt NK
Now that we have Fox3.txt added to the \Windows folder we can now map this to the final destination folder on the device using the .DAT file, like so...
root:-Directory("\"):-Directory("Demo")
Directory("\Demo"):-Directory("FirstFox")
Directory("\Demo\FirstFox"):-File("fox.txt","\windows\fox1.txt")
root:-Directory("\"):-Directory("Demo")
Directory("\Demo"):-Directory("SecondFox")
Directory("\Demo\SecondFox"):-File("fox.txt","\windows\fox2.txt")
root:-Directory("\"):-Directory("Demo")<br>Directory("\Demo"):-Directory("ThirdFox")<br>Directory("\Demo\ThirdFox"):-File("fox.txt","\windows\fox3.txt")
Interestingly, if we open the NK.BIN file in Visual Studio 2005 (our final operating system image for this example) we can see each of the files that are included in the final operating system image, you will notice (simply because there's a big red line around it) that there only the fox1.txt, fox2.txt, and fox3.txt files are in the image - the 'copies' of these files (and the folder structure needed to hold the files) are not created until boot time. The file system will copy any files specified in the initobj.dat file into the folders they are listed for. Keep in mind that all ROM files exist in the \Windows\ folder already, so copying EXE and DLL, or other files to RAM-based folders in a DAT file wastes space.
- Mike
Comments
Anonymous
January 29, 2008
PingBack from http://freedombloghost.info/?p=37854Anonymous
January 29, 2008
Hi, Mike I tried to open nk.bin using VS 2005, but I can't see the display like yours. The nk.bin was displayed in hex. How to view nk.bin in VS 2005 like yours? Thanks!Anonymous
January 30, 2008
bin, in VS 2005 (with CE 6.0 installed) I select: File | Open | File Point the file open dialog to the NK.BIN file, and then click "Open" - the NK.BIN file is opened and I can view the registry and files.
- Mike
Anonymous
January 30, 2008
I am using Wince 5, and haven't install wince 6 yet. Maybe that's why i cann't see the content of nk.bin. Thanks!Anonymous
February 20, 2008
Hi Mike, We tried to build our font driver with CE 6 R2, so we need to copy our font driver DLL into WindowsSystem folder while building binary image. We defined the .dat of our font driver as below: Directory("Windows"):-Directory("System") Directory("WindowsSystem"):-File("MFDrv.dll","WindowsMFDrv.dll") But the MFDrv.dll was not copied into WindowsSystem, what's the problem? Thanks!