2017-12-25 4 views
-3

내 아이폰에있는 기존 sms.db 파일을 xcode 프로젝트로 가져온 수정 된 sms.db 파일로 바꾸고 싶습니다.xcode에서 가져온 .db 파일을 iphone으로 직접 이동하는 방법

"from"및 "to"매개 변수를 사용하는 cp() 함수가 있습니다. 나는 이런 식으로 실행하려면 :

cp('/path/within/xcode/project/sms-modified.db', '/var/mobile/Library/SMS/sms.db'); 
내가 엑스 코드에서 가져온 sms.db을 내 폰 안에 sms.db를 대체 할 수있는 아래의 기능을 수정하는 방법

?

int cp(const char *from, const char *to) { 
    int fd_to, fd_from; 
    char buf[4096]; 
    ssize_t nread; 
    int saved_errno; 

    fd_from = open(from, O_RDONLY); 
    if (fd_from < 0) 
     return -1; 

    fd_to = open(to, O_WRONLY | O_CREAT | O_EXCL, 0666); 
    if (fd_to < 0) 
     goto out_error; 

    while (nread = read(fd_from, buf, sizeof buf), nread > 0) 
    { 
     char *out_ptr = buf; 
     ssize_t nwritten; 

     do { 
      nwritten = write(fd_to, out_ptr, nread); 

      if (nwritten >= 0) 
      { 
       nread -= nwritten; 
       out_ptr += nwritten; 
      } 
      else if (errno != EINTR) 
      { 
       goto out_error; 
      } 
     } while (nread > 0); 
    } 

    if (nread == 0) 
    { 
     if (close(fd_to) < 0) 
     { 
      fd_to = -1; 
      goto out_error; 
     } 
     close(fd_from); 

     /* Success! */ 
     return 0; 
    } 

    out_error: 
    saved_errno = errno; 

    close(fd_from); 
    if (fd_to >= 0) 
     close(fd_to); 

    errno = saved_errno; 
    return -1; 
} 
+0

fopen? 어떤 프로그래밍 언어에 대해 이야기하고 있습니까? 기음? PHP? 누가 iOS 앱에서 macOS 파일에 직접 액세스 할 수 있다고 했습니까? –

+0

C. 파일을 프로젝트로 가져 오면 어떻게 프로젝트에서 가져올 수 있습니까? – Rees

+0

@ElTomato 질문이 업데이 트되었습니다 – Rees

답변

0
내가 엑스 코드에서 가져온 sms.db을 내 폰 안에 sms.db를 대체하기 위해 아래의 기능을 수정하는 방법

?

수 없습니다. 귀하의 아이폰은 "샌드 박스"입니다. 컴퓨터를 "볼"수 없습니다.

+0

sms.db 파일을 프로젝트 파일로 가져온 경우 어떻게해야합니까? 물론, 그 파일을 내 아이폰에 바로 가져올 수 있어야합니까? – Rees

+1

앱에 빌드 할 수 있습니다. 'cp' 함수가 할 수있는 것처럼 파일 시스템을 통해 컴퓨터에서 전화로 파일을 옮기는 것은 불가능합니다. – matt

+0

내가 xdb로 이미 가져온 .db와 함께 내 질문에 더 분명해 졌음이 틀림 없다. – Rees

관련 문제