[ Pobierz całość w formacie PDF ]
.The root user(superuser) can override these permissions.You need to make sure that your application runs under the correctuser and has proper access to required files.Make utility Borland's make utility is not available on the Linux platform.Instead,you can use Linux's own GNU make utility.Multitasking Linux fully supports multitasking.You can run several programs (inLinux, called processes) at the same time.You can launch processes inthe background (using & after the command) and continue workingstraight away.Linux also lets you have several sessions.Pathnames Linux uses a forward slash (/) wherever DOS uses a backslash (\).APathDelim constant can be used to specify the appropriate characterfor the platform.See PathDelim in the runtime library.Search path When executing programs, Windows always checks the currentdirectory first, then looks at the PATH environment variable.Linuxnever looks in the current directory but searches only the directorieslisted in PATH.To run a program in the current directory, youusually have to type./ before it.You can also modify your PATH to include./ as the first path tosearch.Us i ng CLX f or cr os s - pl at f or m dev el opment 10-15Po r t i n g VCL a p p l i c a t i o n s t o CL XTable 10.7 Differences in the Linux and Windows operating environments (continued)Difference DescriptionSearch path separator Windows uses the semicolon as a search path separator.Linux uses acolon.See PathDelim in the runtime library.Symbolic links On Linux, a symbolic link is a special file that points to another file ondisk.Place symbolic links in the global bin directory that points toyour application's main files and you don't have to modify the systemsearch path.A symbolic link is created with the ln (link) command.Windows has shortcuts for the GUI desktop.To make a programavailable at the command line, Windows install programs typicallymodify the system search path.Directory structure on LinuxDirectories are different in Linux.Any file or device can be mounted anywhere onthe file system.Note Linux pathnames use forward slashes as opposed to Windows use of backslashes.The initial slash stands for the root directory.Following are some commonly used directories in Linux.Table 10.8 Common Linux directoriesDirectory Contents/ The root or top directory of the entire Linux file system/root The root file system; the Superuser's home directory/bin Commands, utilities/sbin System utilities/dev Devices shown as files/lib Libraries/home/username Files owned by the user where username is the user's login name./opt Optional/boot Kernel that gets called when the system starts up/etc Configuration files/usr Applications, programs.Usually includes directories like /usr/spool, /usr/man, /usr/include, /usr/local/mnt Other media mounted on the system such as a CD or a floppy disk drive/var Logs, messages, spool files/proc Virtual file system and reporting system statistics/tmp Temporary filesNote Different distributions of Linux sometimes place files in different locations.A utilityprogram may be placed in /bin in a Red Hat distribution but in /usr/local/bin in aDebian distribution.Refer to www.pathname.com for additional details on the organization of the UNIX/Linux hierarchical file system and to read the Filesystem Hierarchy Standard.10-16 Dev el oper s Gui dePo r t i n g VCL a p p l i c a t i o n s t o CL XWriting portable codeIf you are writing cross-platform applications that are meant to run on Windows andLinux, you can write code that compiles under different conditions.Usingconditional compilation, you can maintain your Windows coding, yet also makeallowances for Linux operating system differences.To create applications that are easily portable between Windows and Linux,remember to" reduce or isolate calls to platform-specific (Win32 or Linux) APIs; use CLXmethods instead." eliminate Windows messaging (PostMessage, SendMessage) constructs within anapplication." use TMemIniFile instead of TRegIniFile." observe and preserve case-sensitivity in file and directory names." port any external assembler TASM code.The GNU assembler, as, does notsupport the TASM syntax.(See Including inline assembler code on page 10-20.)Try to write the code to use platform-independent runtime library routines and useconstants found in System, SysUtils, and other runtime library units.For example,use the PathDelim constant to insulate your code from / versus \ platformdifferences.Another example involves the use of multibyte characters on both platforms.Windows code traditionally expects only 2 bytes per multibyte character.In Linux,multibyte character encoding can have many more bytes per char (up to 6 bytes forUTF-8).Both platforms can be accommodated using the StrNextChar function inSysUtils.Existing Windows code such as the followingwhile p^ #0 dobeginif p^ in LeadBytes theninc(p);inc(p);end;can be replaced with platform-independent code like this:while p^ #0 dobeginif p^ in LeadBytes thenp := StrNextChar(p)elseinc(p);end;This example is platform portable and supports multibyte characters longer than 2bytes, but still avoids the performance cost of a procedure call for non-multibytelocales.Us i ng CLX f or cr os s - pl at f or m dev el opment 10-17Po r t i n g VCL a p p l i c a t i o n s t o CL XIf using runtime library functions is not a workable solution, try to isolate theplatform-specific code in your routine into one chunk or into a subroutine.Try tolimit the number of $IFDEF blocks to maintain source code readability andportability.The conditional symbol WIN32 is not defined on Linux
[ Pobierz całość w formacie PDF ]