Subversion Repositories freemyipod

Rev

Rev 770 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 770 Rev 782
Line 373... Line 373...
373
 
373
 
374
int emcore_file_open(uint32_t* handle, const char* path, const int flags)
374
int emcore_file_open(uint32_t* handle, const char* path, const int flags)
375
{
375
{
376
    int res;
376
    int res;
377
    uint32_t str_length, data_length, in[4], *out;
377
    uint32_t str_length, data_length, in[4], *out;
-
 
378
    int flags_emcore = 0;
378
    
379
    
379
    *handle = 0;
380
    *handle = 0;
380
    
381
    
381
    str_length = strlen(path);
382
    str_length = strlen(path);
382
    data_length = str_length + 1 + EMCORE_HEADER_SIZE;
383
    data_length = str_length + 1 + EMCORE_HEADER_SIZE;
Line 387... Line 388...
387
    }
388
    }
388
 
389
 
389
    out = calloc(sizeof(char), data_length);
390
    out = calloc(sizeof(char), data_length);
390
 
391
 
391
    *(out) = 30;
392
    *(out) = 30;
-
 
393
    
-
 
394
    /*
-
 
395
    #define O_RDONLY 0
-
 
396
    #define O_WRONLY 1
-
 
397
    #define O_RDWR   2
-
 
398
    #define O_CREAT  4
-
 
399
    #define O_APPEND 8
-
 
400
    #define O_TRUNC  0x10
-
 
401
    */
-
 
402
    
-
 
403
    if (flags & O_WRONLY) {
-
 
404
        flags_emcore |= 0x01;
-
 
405
    }
-
 
406
    
-
 
407
    if (flags & O_RDWR) {
-
 
408
        flags_emcore |= 0x02;
-
 
409
    }
-
 
410
    
-
 
411
    if (flags & O_CREAT) {
-
 
412
        flags_emcore |= 0x04;
-
 
413
    }
-
 
414
    
-
 
415
    if (flags & O_APPEND) {
-
 
416
        flags_emcore |= 0x08;
-
 
417
    }
-
 
418
    
-
 
419
    if (flags & O_TRUNC) {
-
 
420
        flags_emcore |= 0x10;
-
 
421
    }
-
 
422
    
392
    *(out + 1) = flags;
423
    *(out + 1) = flags_emcore;
393
    
424
    
394
    strncpy(((char*)(out + 4)), path, str_length);
425
    strncpy(((char*)(out + 4)), path, str_length);
395
 
426
 
396
    res = emcore_monitor_command(out, in, data_length, 16);
427
    res = emcore_monitor_command(out, in, data_length, 16);
397
 
428
 
Line 744... Line 775...
744
 
775
 
745
        if (EMCORE_SUCCESS != res)
776
        if (EMCORE_SUCCESS != res)
746
        {
777
        {
747
            return res;
778
            return res;
748
        }
779
        }
749
 
780
        
750
        if (EMCORE_SUCCESS != emcore_errno_value)
781
        if (EMCORE_SUCCESS != emcore_errno_value && 2 != emcore_errno_value)
751
        {
782
        {
752
            return EMCORE_ERROR_IO;
783
            return EMCORE_ERROR_IO;
753
        }
784
        }
754
 
785
 
755
        return EMCORE_ERROR_NO_MORE_ENTRIES;
786
        return EMCORE_ERROR_NO_MORE_ENTRIES;
Line 834... Line 865...
834
    *count = in[1];
865
    *count = in[1];
835
    
866
    
836
    return EMCORE_SUCCESS;
867
    return EMCORE_SUCCESS;
837
}
868
}
838
 
869
 
-
 
870
int emcore_dir_create(const char* name)
-
 
871
{
-
 
872
    int res;
-
 
873
    uint32_t str_length, data_length, in[4], *out;
-
 
874
    
-
 
875
    str_length = strlen(name);
-
 
876
    data_length = str_length + 1 + EMCORE_HEADER_SIZE;
-
 
877
    
-
 
878
    if (data_length > emcore_usb_eps_mps.cout)
-
 
879
    {
-
 
880
        return EMCORE_ERROR_OVERFLOW;
-
 
881
    }
-
 
882
 
-
 
883
    out = calloc(sizeof(char), data_length);
-
 
884
 
-
 
885
    *(out) = 47;
-
 
886
    
-
 
887
    strncpy(((char*)(out + 4)), name, str_length);
-
 
888
 
-
 
889
    res = emcore_monitor_command(out, in, data_length, 16);
-
 
890
 
-
 
891
    if (EMCORE_SUCCESS != res)
-
 
892
    {
-
 
893
        return res;
-
 
894
    }
-
 
895
    
-
 
896
    if (in[1] > 0x80000000)
-
 
897
    {
-
 
898
        return EMCORE_ERROR_IO;
-
 
899
    }
-
 
900
    
-
 
901
    return EMCORE_SUCCESS;
-
 
902
}
-
 
903
 
-
 
904
int emcore_dir_remove(const char* name)
-
 
905
{
-
 
906
    int res;
-
 
907
    uint32_t str_length, data_length, in[4], *out;
-
 
908
    
-
 
909
    str_length = strlen(name);
-
 
910
    data_length = str_length + 1 + EMCORE_HEADER_SIZE;
-
 
911
    
-
 
912
    if (data_length > emcore_usb_eps_mps.cout)
-
 
913
    {
-
 
914
        return EMCORE_ERROR_OVERFLOW;
-
 
915
    }
-
 
916
 
-
 
917
    out = calloc(sizeof(char), data_length);
-
 
918
 
-
 
919
    *(out) = 48;
-
 
920
    
-
 
921
    strncpy(((char*)(out + 4)), name, str_length);
-
 
922
 
-
 
923
    res = emcore_monitor_command(out, in, data_length, 16);
-
 
924
 
-
 
925
    if (EMCORE_SUCCESS != res)
-
 
926
    {
-
 
927
        return res;
-
 
928
    }
-
 
929
    
-
 
930
    if (in[1] > 0x80000000)
-
 
931
    {
-
 
932
        return EMCORE_ERROR_IO;
-
 
933
    }
-
 
934
    
-
 
935
    return EMCORE_SUCCESS;
-
 
936
}
-
 
937
 
839
int emcore_errno(uint32_t* emcore_errno_value)
938
int emcore_errno(uint32_t* emcore_errno_value)
840
{
939
{
841
    int res;
940
    int res;
842
    uint32_t out[4] = { 49, 0, 0, 0 }, in[4];
941
    uint32_t out[4] = { 49, 0, 0, 0 }, in[4];
843
 
942