메뉴 건너뛰기


Developer > Application
다음의 내용은 Addison Wesley Professional사에서 출판한
Johnson M. Hart가 쓴 Windows System Programming Third Edition라는 책에서 부록B를 발췌한 내용입니다. 

Appendix B. Windows, UNIX, and C Library Comparisons

The tables in this appendix show the Windows (Win32 and Win64) functions described in the main text along with the corresponding UNIX/Linux[1] and ANSI Standard C library functions, if any.

 

[1] More precisely, "UNIX" means the POSIX functions specified in The Single UNIX Specification (http://www.opengroup.org/onlinepubs/007908799/). UNIX and Linux implement this specification. In turn, the specification has its historical origins in UNIX.

The tables are arranged by chapter (some chapters are combined). Within each chapter, they are sorted first by functionality area (file system, directory management, and so on) and then by the Windows function name.

Each table row gives the following information:

  • The functionality area (subject)

  • The Windows function name

  • The corresponding UNIX function name. In some cases, there are more than one.

  • The corresponding C library function name, if any

  • Comments as appropriate

The notation used in the tables requires some explanation.

  • The Microsoft Visual C++ library contains some UNIX compatibility functions. For example, _open is the compatibility library function for UNIX open. If the UNIX function is in italics, there is a compatibility function. An asterisk next to the name indicates that there is also a wide character Unicode version. For example, there is a _wopen function.

  • A program that uses just the Standard C library, and no Windows or UNIX system functions, should compile, build, and run on both systems if normal precautions are taken. Such a program will, however, be limited to file and I/O operations.

  • Commas separating functions indicate alternatives, often using different characteristics or emulating one aspect of the Windows function.

  • Semicolons separating functions indicate that you use the functions in sequence to emulate the Windows function. Thus, fork; exec corresponds to CreateProcess.

  • An underlined entry indicates a global variable, such as errno.

  • In a few cases, the UNIX equivalent may be stated imprecisely in terms such as "terminal I/O" for Windows functions such as AllocConsole. Often, "Use C library" is the appropriate comment, as in the case of GetTempFileName. In other cases, the situation is reversed. Thus, under the UNIX signal management functions (sigaddset and so on), the Windows entry is "Use SEHVEH" to indicate that the programmer should set up structured or vectored exception handlers and filter functions to get the desired behavior. Unlike UNIX, Windows does not support process groups, so the Windows entries are "N/A," although job management, as done by the programs in Chapter 6, could emulate process relationships.

  • There are numerous "N/A" entries, especially for the C library, if there is no comparable function or set of functions. This is the case, for example, with directory management.

  • The POSIX threads (Pthreads) functions are the UNIX equivalents shown in the tables for Chapters 710, even though they are not properly a part of UNIX. Furthermore, even though many UNIX implementations have their own synchronization objects similar to events, mutexes, and semaphores, there is no attempt to list them here.

Generally, the correspondence is more precise in the earlier chapters, particularly for file management. The systems tend to diverge with the more advanced functionality and, in many cases, there is no C library equivalent. For example, the UNIX and Windows security models differ significantly, so the relationships shown are, at best, approximations.

These functional correspondences are not exact. There are many differences, small and large, among the three systems. Therefore, these tables are only for guidance. The individual chapters discuss many of the differences.

Chapters 2 and 3: File and Directory Management

SubjectWindowsUNIXC LibraryComments
Console I/OAllocConsoleterminal I/ON/A 
Console I/OFreeConsoleterminal I/ON/A 
Console I/OReadConsolereadgetc, scanf, gets 
Console I/OSetConsoleModeioctlN/A 
Console I/OWriteConsolewriteputc, printf, puts 
Directory MgtCreateDirectorymkdir*N/AMake a new directory
Directory MgtFindCloseclosedir*N/AClose a directory search handle
Directory MgtFindFirstFileopendir*, readdir*N/AFind first file matching a pattern
Directory MgtFindNextFilereaddir*N/AFind subsequent files
Directory MgtGetCurrentDirectorygetcwd*N/A 
Directory MgtGetFullPathNameN/AN/A 
Directory MgtGetSystemDirectoryWell-known pathnamesN/A 
Directory MgtRemoveDirectoryrmdir, unlink*remove 
Directory MgtSearchPathUse opendir, readdirN/ASearch for a file on a specified path
Directory MgtSetCurrentDirectorychdir*, fchdirN/AChange the working directory
Error HandlingFormatMessagestrerrorperror 
Error HandlingGetLastErrorerrnoerrnoGlobal variable
Error HandlingSetLastErrorerrnoerrnoGlobal variable
File LockingLockFilefcntl (cmd=F_GETLK, ..)N/A 
File LockingLockFileExfcntl (cmd=F_GETLK, ..)N/A 
File LockingUnlockFilefcntl (cmd=F_GETLK, ..)N/A 
File LockingUnlockFileExfcntl (cmd=F_GETLK, ..)N/A 
File SystemCloseHandle (file handle)close*fcloseCloseHandle is not limited to files
File SystemCopyFileopen; read; write; closefopen; fread; fwrite; fcloseDuplicate a file
File SystemCreateFileopen*, creat*fopenOpen/create a file
File SystemDeleteFileunlink*removeDelete a file
File SystemFlushFileBuffersfsynchfflushWrite file buffers
File SystemGetFileAttributesstat*, fstat*, lstatN/A 
File SystemGetFileInformationByHandlestat*, fstat*, lstatN/AFill structure with file info
File SystemGetFileSizestat*, fstat*, lstatftell, fseekGet length of file in bytes
File SystemGetFileTimestat*, fstat*, lstatN/A 
File SystemGetFileTypestat*, fstat*, lstatN/ACheck for character stream device or file
File SystemGetStdHandleUse file desc 0, 1, or 2Use stdinstdoutstderr 
File SystemGetTempFileNameUse C librarytmpnamCreate a unique file name
File SystemGetTempFileName, CreateFileUse C librarytmpfileCreate a temporary file
File SystemGetTempPath/temp pathN/ADirectory for temp files
File SystemMoveFile, MoveFileExUse C libraryrenameRename a file or directory
File SystemCreateHardLinklink, unlink*N/AWindows does not support links
File SystemN/AsymlinkN/ACreate a symbolic link
File SystemN/AreadlinkN/ARead name in a symbolic link
File SystemN/A, ReadFile returns 0 bytesN/A, read returns 0 bytesfeofRest for end of file
File SystemN/A, use multiple ReadFilesreadvN/A, use multiple freadsScatter read
File SystemN/A, use multiple WriteFileswritevN/A, use multiple fwritesGather write
File SystemReadFilereadfreadRead data from a file
File SystemSetEndOfFilechsize*N/A 
File SystemSetFileAttributesfcntlN/A 
File SystemSetFilePointerlseekfseekSet file pointer
FileSystemSetFilePointer (to 0)lseek (0)rewind 
File SystemSetFileTimeutime*N/A 
File SystemSetStdHandleclose, dup*, dup2*, or fcntlfreopendup2 or fcntl
File SystemWriteFilewritefwriteWrite data to a file
System InfoGetDiskFreeSpaceN/AN/A 
System InfoGetSystemInfogetrusageN/A 
System InfoGetVersionunameN/A 
System InfoGetVolumeInformationN/AN/A 
System InfoGlobalMemoryStatusgetrlimitN/A 
System InfoVarious defined constantssysconf, pathconf, fpathconfN/A 
TimeGetSystemTimeUse C librarytime, gmtime 
TimeSee ls program, Program 3-2Use C libraryasctime 
TimeCompareFileTimeUse C librarydifftimeCompare "calendar" times
TimeFileTimeToLocalFileTime, FileTimeToSystemTimeUse C librarylocaltime 
TimeFileTimeToSystemTimeUse C librarygmtime 
TimeGetLocalTimeUse C librarytime, localtime 
TimeSee touch program, Program 3-3Use C librarystrftime 
TimeSetLocalTimeN/AN/A 
TimeSetSystemTimeN/AN/A 
TimeSubtract file timesUse C librarydifftime 
TimeSystemTimeToFileTimeUse C librarymktime 

번호 제목 글쓴이 날짜 조회 수
38 Windows에서 GetLastError()의 에러 메시지 내용 출력하기 푸우 2013.11.27 13086
37 윈도우즈, 유닉스, C라이브러리 비교 - Securing Windows Objects 푸우 2013.11.27 18998
36 윈도우즈, 유닉스, C라이브러리 비교 - Asynchronous I/O 푸우 2013.11.27 18820
35 윈도우즈, 유닉스, C라이브러리 비교 - Interprocess Communication 푸우 2013.11.27 20552
34 윈도우즈, 유닉스, C라이브러리 비교 - Thread Synchronization 푸우 2013.11.27 20366
33 윈도우즈, 유닉스, C라이브러리 비교 - Threads and Scheduling 푸우 2013.11.27 19243
32 윈도우즈, 유닉스, C라이브러리 비교 - Process Management 푸우 2013.11.27 20522
31 윈도우즈, 유닉스, C라이브러리 비교 - Memory Management, Memory-Mapped Files, and DLLs 푸우 2013.11.27 21289
30 윈도우즈, 유닉스, C라이브러리 비교 - Exception Handling 푸우 2013.11.27 19214
» 윈도우즈, 유닉스, C라이브러리 비교 - File and Directory Management 푸우 2013.11.27 27820
28 BASE64 인코딩 디코딩 file 푸우 2013.11.27 18901
27 mms client file 푸우 2013.11.26 13225
26 The SNIPPETS Portable C++ Source Code Archive file 푸우 2013.11.26 19653
25 The SNIPPETS Portable C Source Code Archive file 푸우 2013.11.26 13774
24 Email 포맷인 eml파일의 필터링을 위한 라이브러리 file 푸우 2013.11.26 13643
23 Linux, Unix에서 라이브러리 만들기 file 푸우 2013.11.26 13306
22 Zlib를 이용한 프로그래밍 푸우 2013.11.26 14054
21 Bit Field를 이용한 구조체 크기 줄이기 푸우 2013.11.26 13480
20 C++ 에서 C 함수의 사용하기 푸우 2013.11.26 13690
19 MD5 라이브러리 file 푸우 2013.11.26 12741