summaryrefslogtreecommitdiff
path: root/fatfs/doc/ja/lseek.html
blob: 55788526279c8a118c9932369419306f762098d1 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/lseek.html">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_lseek</title>
</head>

<body>

<div class="para func">
<h2>f_lseek</h2>
<p>�t�@�C���̃��[�h/���C�g�E�|�C���^���ړ����܂��B�܂��A�����V�[�N�@�\�g�p���ɂ�CLMT(��q)�̍쐬�ɂ��g�p���܂��B</p>
<pre>
FRESULT f_lseek (
  FIL* <span class="arg">fp</span>,    <span class="c">/* [IN] �t�@�C���E�I�u�W�F�N�g�\���̂ւ̃|�C���^ */</span>
  DWORD <span class="arg">ofs</span>   <span class="c">/* [IN] �ړ���I�t�Z�b�g */</span>
);
</pre>
</div>

<div class="para arg">
<h4>����</h4>
<dl class="par">
<dt>fp</dt>
<dd>�ΏۂƂȂ�t�@�C���E�I�u�W�F�N�g�\���̂ւ̃|�C���^���w�肵�܂��B</dd>
<dt>ofs</dt>
<dd>�ړ���̃I�t�Z�b�g(���[�h/���C�g�E�|�C���^)�l�B�t�@�C���擪����̃I�t�Z�b�g���o�C�g�P�ʂŎw�肵�܂��B</dd>
</dl>
</div>


<div class="para ret">
<h4>�߂�l</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
</p>
</div>


<div class="para desc">
<h4>���</h4>
<p>�t�@�C���̃��[�h/���C�g�E�|�C���^(���ɓǂݏo���E�������݂����o�C�g�̃I�t�Z�b�g)���ړ����܂��B�I�t�Z�b�g�̌��_�̓t�@�C���擪�ł��B�������݃��[�h�Ńt�@�C���E�T�C�Y���傫�Ȓl���w�肷��ƁA�����܂Ńt�@�C���E�T�C�Y���g������A�g�����ꂽ�����̃f�[�^�͖���`�ƂȂ�܂��B�f�[�^��x�����������ɏ������݂����Ƃ��́A�\�߂��̊֐��ŕK�v�ȃT�C�Y�܂Ńt�@�C���E�T�C�Y���g�����Ă����Ɨǂ��ł��傤�B<tt>f_lseek()</tt>������I���������Ƃ́A���[�h/���C�g�E�|�C���^���������ړ��������`�F�b�N����ׂ��ł��B���[�h/���C�g�E�|�C���^���w���菬�����Ƃ��́A���̌������l�����܂��B</p>
<ul>
<li>�񏑂����݃��[�h�܂��͍����V�[�N�E���[�h�̂��߁A�t�@�C���E�T�C�Y�ŃN���b�v���ꂽ�B</li>
<li>�t�@�C���g�����Ƀf�B�X�N�����t�ɂȂ����B</li>
</ul>
<p><tt>_USE_FASTSEEK</tt>��1�ŁA���ƒt�@�C���E�I�u�W�F�N�g��<tt>cltbl</tt>�����o��NULL�ȊO(<tt>f_open()</tt>��NULL�ɐݒ肳���)�̂Ƃ��A�����V�[�N�E���[�h�ɂȂ�܂��B����̓t�@�C���̃N���X�^�z�u���(CLMT)����������ɕێ����Ă������Ƃɂ��AFAT�ɃA�N�Z�X���邱�ƂȂ�����V�[�N�⃍���O�E�V�[�N�������ɍs���@�\�ł��B�����V�[�N�E���[�h�́A<tt>f_read()/f_wtite()</tt>�̓���ɂ��K�p����܂��B�����V�[�N�E���[�h�ł�<tt>f_wtite()/f_lseek()</tt>�ɂ��t�@�C���E�T�C�Y�̊g���͂ł��܂���B</p>
<p>�����V�[�N������s���O�ɁACLMT���쐬���Ă����K�v������܂��B������쐬����ɂ́A�܂�CLMT�i�[�o�b�t�@(<tt>DWORD</tt>�^�z��)���������A<tt>cltbl</tt>�����o�ɂ��̃|�C���^���Z�b�g���܂��B�����āA�z��̐擪�v�f�ɂ��̔z��̃T�C�Y(�v�f��)�����A<tt>f_lseek()</tt>��<tt class="arg">ofs</tt>��<tt>CREATE_LINKMAP</tt>���w�肵�ČĂяo���܂��B�֐������������CLMT���쐬����A�ȍ~��<tt>f_read()/f_write()/f_lseek()</tt>�ł�FAT�ւ̃A�N�Z�X�͔������܂���B<tt>FR_NOT_ENOUGH_CORE</tt>�Ŏ��s�����Ƃ��͔z��T�C�Y���s���ŁA�擪�v�f�ɂ͎��ۂɕK�v�ƂȂ�v�f�����Ԃ���܂��B�K�v�ȗv�f���́A(�t�@�C���̕����� + 1) * 2 �ł��B���Ƃ��΁A�t�@�C����5�‚̃t���O�����g�ɕ��f����Ă���Ƃ��ɕK�v�ȗv�f���́A12�ƂȂ�܂��B</p>
</div>


<div class="para comp">
<h4>�Ή����</h4>
<p><tt>_FS_MINIMIZE &lt; 3</tt>�̂Ƃ��g�p�”\�ł��B</p>
</div>


<div class="para use">
<h4>�g�p��</h4>
<pre>
    <span class="c">/* �t�@�C�����J�� */</span>
    fp = malloc(sizeof (FIL));
    res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
    if (res) ...

    <span class="c">/* �t�@�C���E�I�t�Z�b�g5000�ֈړ� */</span>
    res = f_lseek(fp, 5000);

    <span class="c">/* �t�@�C���I�[�ֈړ�(�t�@�C���NjL�̏���) */</span>
    res = f_lseek(fp, f_size(fp));

    <span class="c">/* 3000�o�C�g�i�߂� */</span>
    res = f_lseek(fp, f_tell(fp) + 3000);

    <span class="c">/* 2000�o�C�g�߂� (���b�v�A���E���h�ɒ���) */</span>
    res = f_lseek(fp, f_tell(fp) - 2000);
</pre>
<pre>
<span class="c">/* �N���X�^��s���蓖�� (�X�g���[�~���O�E���C�g���̃o�b�t�@�E�I�[�o�[�����h�~) */</span>

    res = f_open(fp, "record.wav", FA_CREATE_NEW | FA_WRITE);    <span class="c">/* �t�@�C���쐬 */</span>

    res = f_lseek(fp, MAX_SIZE);             <span class="c">/* �\���ȃN���X�^�̐�s���蓖�� */</span>
    if (res || f_tell(fp) != PRE_SIZE) ...   <span class="c">/* �������t�@�C�����g�����ꂽ���`�F�b�N */</span>

    res = f_lseek(fp, DATA_START);           <span class="c">/* �f�[�^�E�X�g���[���̋L�^(�A���P�[�V�����f�B���C����) */</span>
    ...

    res = f_truncate(fp);                    <span class="c">/* �s�v�̈�̐؂�̂� */</span>
    res = f_lseek(fp, 0);                    <span class="c">/* �w�b�_�̋L�^ */</span>
    ...

    res = f_close(fp);
</pre>
<pre>
<span class="c">/* �����V�[�N�@�\���g�� */</span>

    DWORD clmt[SZ_TBL];                    <span class="c">/* �����N�E�}�b�v�E�e�[�u���i�[�o�b�t�@ */</span>

    res = f_lseek(fp, ofs1);               <span class="c">/* �ʏ�V�[�N (�I�[�v�����Acltbl��NULL�ɏ����������) */</span>

    fp-&gt;cltbl = clmt;                      <span class="c">/* �����V�[�N�@�\�̗L���� */</span>
    clmt[0] = SZ_TBL;                      <span class="c">/* �擪�v�f�ɔz��v�f�����Z�b�g */</span>
    res = f_lseek(fp, CREATE_LINKMAP);     <span class="c">/* CLMT�̍쐬 */</span>
    ...

    res = f_lseek(fp, ofs2);               <span class="c">/* �ȍ~�Af_read/f_write/f_lseek��FAT�A�N�Z�X�͔������Ȃ� */</span>
</pre>
</div>


<div class="para ref">
<h4>�Q��</h4>
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
</div>

<p class="foot"><a href="../00index_j.html">�߂�</a></p>
</body>
</html>