예제 #1
0
파일: c_path.c 프로젝트: ArthurChiao/client
 mbchar_t* c_utf8_path_to_locale(const char *str)
 {
     if( str == NULL ) {
         return NULL;
     } else {
 #ifdef _WIN32
         const char *unc_str = c_path_to_UNC(str);
         mbchar_t *dst = c_utf8_string_to_locale(unc_str);
         SAFE_FREE(unc_str);
         return dst;
 #else
         return c_utf8_string_to_locale(str);
 #endif
     }
 }
예제 #2
0
int csync_fnmatch(__const char *__pattern, __const char *__name, int __flags) {
    wchar_t *pat = NULL;
    wchar_t *name = NULL;
    BOOL match;

    (void) __flags;

    name = c_utf8_string_to_locale(__name);
    pat  = c_utf8_string_to_locale(__pattern);

    match = PathMatchSpecW(name, pat);

    c_free_locale_string(pat);
    c_free_locale_string(name);
    if(match)
        return 0;
    else
        return 1;
}
예제 #3
0
static void output( const char *text )
{
    mbchar_t *wtext = c_utf8_string_to_locale(text);

    #ifdef _WIN32
    wprintf(L"OOOO %ls (%ld)\n", wtext, strlen(text));
    #else
    printf("%s\n", wtext);
    #endif
    c_free_locale_string(wtext);
}
예제 #4
0
static void create_file( const char *path, const char *name, const char *content)
{
#ifdef _WIN32

  char *filepath = c_malloc( 2+strlen(CSYNC_TEST_DIR)+strlen(path) + strlen(name) );
  *filepath = '\0';
  strcpy(filepath, CSYNC_TEST_DIR);
  strcat(filepath, "/");
  strcat(filepath, path);
  strcat(filepath, name);

  DWORD dwWritten; // number of bytes written to file
  HANDLE hFile;

  mbchar_t *w_fname = c_utf8_path_to_locale(filepath);

  hFile=CreateFile(w_fname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0,
                            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

  assert_int_equal( 0, hFile==INVALID_HANDLE_VALUE );

  int len = strlen(content);
  mbchar_t *dst = NULL;

  dst = c_utf8_string_to_locale(content);
  WriteFile(hFile, dst, len * sizeof(mbchar_t), &dwWritten, 0);

  CloseHandle(hFile);
  SAFE_FREE(dst);
  c_free_locale_string(w_fname);
#else
   char *filepath = c_malloc( 1+strlen(path) + strlen(name) );
   *filepath = '\0';

   strcpy(filepath, path);
   strcat(filepath, name);

   FILE *sink;
   sink = fopen(filepath,"w");

   fprintf (sink, "we got: %s",content);
   fclose(sink);
   SAFE_FREE(filepath);
#endif

}