summaryrefslogtreecommitdiff
path: root/wince/fileops.c
blob: b0617bd31bbdc3462edac52a1b8c948761eb81fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// "Extension" implementation of ANSI C file functions for Windows CE.
//
// I (Simon Howard) release this file to the public domain.
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <windows.h>

#include "fileops.h"

int remove(const char *pathname)
{
    wchar_t temp[MAX_PATH + 1];

    MultiByteToWideChar(CP_OEMCP,
                        0,
                        pathname,
                        strlen(pathname) + 1,
                        temp,
                        MAX_PATH);

    return DeleteFileW(temp) != 0;
}

int rename(const char *oldpath, const char *newpath)
{
    wchar_t oldpath1[MAX_PATH + 1];
    wchar_t newpath1[MAX_PATH + 1];

    MultiByteToWideChar(CP_OEMCP,
                        0,
                        oldpath,
                        strlen(oldpath) + 1,
                        oldpath1,
                        MAX_PATH);
    MultiByteToWideChar(CP_OEMCP,
                        0,
                        newpath,
                        strlen(newpath) + 1,
                        newpath1,
                        MAX_PATH);

    return MoveFileW(oldpath1, newpath1);
}