From: <ped...@us...> - 2007-06-24 19:42:32
|
Revision: 992 http://svn.sourceforge.net/cegcc/?rev=992&view=rev Author: pedroalves Date: 2007-06-24 12:42:31 -0700 (Sun, 24 Jun 2007) Log Message: ----------- * mingwex/wince/findfile.c: New file. * mingwex/wince/chsize.c: New file. * mingwex/wince/access.c: New file. * mingwex/wince/mkdir.c: New file. * mingwex/wince/rmdir.c: New file. Modified Paths: -------------- trunk/cegcc/src/mingw/ChangeLog.mingw32ce Added Paths: ----------- trunk/cegcc/src/mingw/mingwex/wince/access.c trunk/cegcc/src/mingw/mingwex/wince/chsize.c trunk/cegcc/src/mingw/mingwex/wince/findfile.c trunk/cegcc/src/mingw/mingwex/wince/mkdir.c trunk/cegcc/src/mingw/mingwex/wince/rmdir.c Modified: trunk/cegcc/src/mingw/ChangeLog.mingw32ce =================================================================== --- trunk/cegcc/src/mingw/ChangeLog.mingw32ce 2007-06-24 19:30:58 UTC (rev 991) +++ trunk/cegcc/src/mingw/ChangeLog.mingw32ce 2007-06-24 19:42:31 UTC (rev 992) @@ -1,5 +1,13 @@ 2007-06-24 Pedro Alves <ped...@po...> + * mingwex/wince/findfile.c: New file. + * mingwex/wince/chsize.c: New file. + * mingwex/wince/access.c: New file. + * mingwex/wince/mkdir.c: New file. + * mingwex/wince/rmdir.c: New file. + +2007-06-24 Pedro Alves <ped...@po...> + * mingwex/wince/bsearch.c: New file. 2007-06-24 Pedro Alves <ped...@po...> Added: trunk/cegcc/src/mingw/mingwex/wince/access.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/wince/access.c (rev 0) +++ trunk/cegcc/src/mingw/mingwex/wince/access.c 2007-06-24 19:42:31 UTC (rev 992) @@ -0,0 +1,43 @@ +/* This is file ACCESS.C */ +/* + * Copyright (C) 1993 DJ Delorie + * All rights reserved. + * + * Redistribution and use in source and binary forms is permitted + * provided that the above copyright notice and following paragraph are + * duplicated in all such forms. + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* PAlves: + Renamed access to _access, and made a new access + that calls _access. */ + +#include <fcntl.h> +#include <sys/stat.h> +#include <unistd.h> + +int +_access(const char *fn, int flags) +{ + struct stat s; + if (stat(fn, &s)) + return -1; + if (s.st_mode & S_IFDIR) + return 0; + if (flags & W_OK) + { + if (s.st_mode & S_IWRITE) + return 0; + return -1; + } + return 0; +} + +int +access(const char *fn, int flags) +{ + return _access(fn, flags); +} Property changes on: trunk/cegcc/src/mingw/mingwex/wince/access.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/cegcc/src/mingw/mingwex/wince/chsize.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/wince/chsize.c (rev 0) +++ trunk/cegcc/src/mingw/mingwex/wince/chsize.c 2007-06-24 19:42:31 UTC (rev 992) @@ -0,0 +1,51 @@ +/* + * chsize.c: _chsize and chsize implementations for WinCE. + * + * This file has no copyright assigned and is placed in the Public + * Domain. This file is a part of the mingw32ce package. No + * warranty is given; refer to the file DISCLAIMER within the package. + * + * Written by Pedro Alves <ped...@po...> 24 Jun 2007 + * + */ + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +int +_chsize (int fd, long size) +{ + DWORD cur; + DWORD new; + HANDLE h; + BOOL ret; + + h = (HANDLE) fd; + if (h == INVALID_HANDLE_VALUE) + { + SetLastError (ERROR_INVALID_PARAMETER); + return -1; + } + + cur = SetFilePointer (h, 0, NULL, FILE_CURRENT); + if (cur == 0xffffffff) + return -1; + + /* Move to where we want it. */ + new = SetFilePointer (h, size, NULL, FILE_BEGIN); + if (new == 0xffffffff) + return -1; + + /* And commit it as eof, effectivelly growing or shrinking. */ + ret = SetEndOfFile (h); + + SetFilePointer (h, cur, NULL, FILE_BEGIN); + + return ret ? 0 : -1; +} + +int +chsize (int fd, long size) +{ + return _chsize (fd, size); +} Property changes on: trunk/cegcc/src/mingw/mingwex/wince/chsize.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/cegcc/src/mingw/mingwex/wince/findfile.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/wince/findfile.c (rev 0) +++ trunk/cegcc/src/mingw/mingwex/wince/findfile.c 2007-06-24 19:42:31 UTC (rev 992) @@ -0,0 +1,128 @@ +/* + * findfind.c: _findfirst, _findnext, _findclose and the wide + * counterparts implementations for WinCE. + * + * This file has no copyright assigned and is placed in the Public + * Domain. This file is a part of the mingw32ce package. No + * warranty is given; refer to the file DISCLAIMER within the package. + * + * Written by Pedro Alves <ped...@po...> 24 Jun 2007 + * + */ + +#include <stdarg.h> +#include <time.h> +#include <windows.h> +#include <io.h> +#include "timeutil.h" + +static void +wfd_to_fd (const WIN32_FIND_DATAW *wfd, struct _wfinddata_t *fd) +{ + /* Map win32 file attributes to _finddata_t types. The constants + are numerically equal, meaning we could also: + fd->attrib = wfd->dwFileAttributes; + But that would copy too much. + TODO: _A_VOLID isn't mapped. */ + + fd->attrib = 0; + if (wfd->dwFileAttributes & FILE_ATTRIBUTE_NORMAL) + fd->attrib |= _A_NORMAL; + if (wfd->dwFileAttributes & FILE_ATTRIBUTE_READONLY) + fd->attrib |= _A_RDONLY; + if (wfd->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) + fd->attrib |= _A_HIDDEN; + if (wfd->dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) + fd->attrib |= _A_SYSTEM; + if (wfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + fd->attrib |= _A_SUBDIR; + if (wfd->dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) + fd->attrib |= _A_ARCH; + + fd->size = wfd->nFileSizeLow; + wcscpy (fd->name, wfd->cFileName); + + fd->time_access = __FILETIME_to_time_t (&wfd->ftLastAccessTime); + fd->time_create = __FILETIME_to_time_t (&wfd->ftCreationTime); + fd->time_write = __FILETIME_to_time_t (&wfd->ftLastWriteTime); +} + +static void +tofinddataa (struct _finddata_t *fda, const struct _wfinddata_t *fdw) +{ +#define COPY_MEMBER(MEM) do { fda->MEM = fdw->MEM; } while (0) + COPY_MEMBER (attrib); + COPY_MEMBER (time_create); + COPY_MEMBER (time_access); + COPY_MEMBER (time_write); + COPY_MEMBER (size); +#undef COPY_MEMBER + wcstombs (fda->name, fdw->name, FILENAME_MAX); +}; + +int +_findclose (long h) +{ + if (!FindClose ((HANDLE) h)) + return -1; + return 0; +} + +long +_wfindfirst (const wchar_t *filespec, struct _wfinddata_t *f) +{ + WIN32_FIND_DATAW find_data; + HANDLE h; + + h = FindFirstFileW (filespec, &find_data); + if (h == INVALID_HANDLE_VALUE) + return -1; + + wfd_to_fd (&find_data, f); + return (long) h; +} + +long +_findfirst (const char *filespec, struct _finddata_t *f) +{ + wchar_t wfilespec[MAX_PATH]; + struct _wfinddata_t wf; + long h; + + mbstowcs (wfilespec, filespec, MAX_PATH); + + h = _wfindfirst (wfilespec, &wf); + + if (h == -1) + return -1; + + tofinddataa (f, &wf); + return h; +} + +int +_wfindnext (long h, struct _wfinddata_t *f) +{ + WIN32_FIND_DATAW find_data; + + if (!FindNextFileW ((HANDLE) h, &find_data)) + return -1; + + wfd_to_fd (&find_data, f); + return 0; +} + +int +_findnext (long h, struct _finddata_t * f) +{ + struct _wfinddata_t wf; + int ret; + + ret = _wfindnext (h, &wf); + + if (ret == -1) + return -1; + + tofinddataa (f, &wf); + return h; +} Property changes on: trunk/cegcc/src/mingw/mingwex/wince/findfile.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/cegcc/src/mingw/mingwex/wince/mkdir.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/wince/mkdir.c (rev 0) +++ trunk/cegcc/src/mingw/mingwex/wince/mkdir.c 2007-06-24 19:42:31 UTC (rev 992) @@ -0,0 +1,29 @@ +/* + * mkdir.c: mkdir implementation for WinCE. + * + * This file has no copyright assigned and is placed in the Public + * Domain. This file is a part of the mingw32ce package. No + * warranty is given; refer to the file DISCLAIMER within the package. + * + * Written by Pedro Alves <ped...@po...> 24 Jun 2007 + * + */ + +#include <windows.h> +#include <io.h> + +int +_mkdir (const char *dirname) +{ + wchar_t dirnamew[MAX_PATH]; + mbstowcs (dirnamew, dirname, MAX_PATH); + if (!CreateDirectoryW (dirnamew, NULL)) + return -1; + return 0; +} + +int +mkdir (const char *dirname) +{ + return _mkdir (dirname); +} Property changes on: trunk/cegcc/src/mingw/mingwex/wince/mkdir.c ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/cegcc/src/mingw/mingwex/wince/rmdir.c =================================================================== --- trunk/cegcc/src/mingw/mingwex/wince/rmdir.c (rev 0) +++ trunk/cegcc/src/mingw/mingwex/wince/rmdir.c 2007-06-24 19:42:31 UTC (rev 992) @@ -0,0 +1,31 @@ +/* + * rmdir.c: rmdir implementation for WinCE. + * + * This file has no copyright assigned and is placed in the Public + * Domain. This file is a part of the mingw32ce package. No + * warranty is given; refer to the file DISCLAIMER within the package. + * + * Written by Pedro Alves <ped...@po...> 24 Jun 2007 + * + */ + +#include <windows.h> +#include <io.h> + +int +rmdir (const char *dirname) +{ + wchar_t dirnamew[MAX_PATH + 1]; + + if (dirname == NULL) + { + SetLastError (ERROR_INVALID_ADDRESS); + return -1; + } + + mbstowcs (dirnamew, dirname, MAX_PATH); + if (!RemoveDirectoryW (dirnamew)) + return -1; + + return 0; +} Property changes on: trunk/cegcc/src/mingw/mingwex/wince/rmdir.c ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |