Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Прочее";
Текущий архив: 2009.04.12;
Скачать: [xml.tar.bz2];

Вниз

Какая-то непонятная "нестыковка" Борланда и МС   Найти похожие ветки 

 
Германн ©   (2009-02-13 01:20) [0]

API-шные функции требуют, чтобы передаваемые им имена файлов были заключены в кавычки, если эти имена не укладываются в стандарт 8.3.
А дельфийские функции (FileExists например), наоборот ругаются на эти кавычки.


 
Игорь Шевченко ©   (2009-02-13 01:31) [1]


> API-шные функции требуют, чтобы передаваемые им имена файлов
> были заключены в кавычки, если эти имена не укладываются
> в стандарт 8.3


Не требуют


 
Германн ©   (2009-02-13 01:42) [2]


> Игорь Шевченко ©   (13.02.09 01:31) [1]

Ну да?  Не требуют!?


 
Eraser ©   (2009-02-13 03:13) [3]

> [2] Германн ©   (13.02.09 01:42)

не требуют, но это отдельный разговор.. зависит от конкретной функции. на базе этого есть ряд уязвимостей, описано у Ховарда в "защищенном коде".


 
XentaAbsenta ©   (2009-02-13 09:17) [4]

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/fileio/fs/naming_a_file.htm

 
Platform SDK: File Systems
Naming a File
Although each file system can have specific rules about the formation of individual components in a directory or file name, all file systems follow the same general conventions: a base file name and an optional extension, separated by a period.

For example, the MS-DOS FAT file system supports 8 characters for the base file name and 3 characters for the extension. This is known as an 8.3 file name. The FAT file system and the NTFS file system are not limited to 8.3 file names, because they support a long file name.

Naming Conventions

The following rules enable applications to create and process valid names for files and directories regardless of the file system:

Use a period (.) to separate the base file name from the extension in a directory name or file name.
Backslashes (\) are used to separate components in paths, which divides the file name from the path to it, or one directory from one another in a path. You cannot use backslashes in file or directory names. However, they can be required as part of volume names, for example, "C:\". UNC names must adhere to the following format: \\<server>\<share>.
Use any character in the current code page for a name, except characters in the range of 0 through 31, or any character that the file system does not allow. A name can contain characters in the extended character set (128–255). However, it cannot contain the following reserved characters:
< > : " / \ |

The following reserved device names cannot be used as the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed by an extension, for example, NUL.tx7.
Windows NT:  CLOCK$ is also a reserved device name.
Do not assume case sensitivity. Consider names such as OSCAR, Oscar, and oscar to be the same.
Do not end a file or directory name with a trailing space or a period. Although the underlying file system may support such names, the operating system does not.
Use a period (.) as a directory component in a path to represent the current directory.
Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory.

Maximum Path Length
In the Windows API, the maximum length for a path is MAX_PATH, which is defined as 260 characters. A path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a null-terminating character, for example, the maximum path on the D drive is D:\<256 chars>NUL.

The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length. To specify that kind of path, use the "\\?\" prefix.

Note  The maximum path of 32,000 characters is approximate, because the "\\?\" prefix can be expanded to a longer string, and the expansion applies to the total length.

For example, "\\?\D:\<path>". To specify such a UNC path, use the "\\?\UNC\" prefix. For example, "\\?\UNC\<server>\<share>". These prefixes are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification. An implication of this is that you cannot use forward slashes to represent path separators, or a period to represent the current directory. You cannot use the "\\?\" prefix with a relative path. Relative paths are limited to MAX_PATH characters.

When using the API to create a directory, the specified path cannot be so long that you could not append an 8.3 file name.

The shell and the file system may have different requirements. It is possible to create a path with the API that the shell UI cannot handle.

Relative Paths

For functions that manipulate files, the file names may be relative to the current directory. A file name is relative to the current directory if it does not begin with a disk designator or directory name separator, such as a backslash (\). If the file name begins with a disk designator, it is a full path.

Short and Long File Names

Windows normally stores the long file names on disk as special directory entries (this can be disabled for performance reasons). When you create a long file name, Windows also creates the short MS-DOS (8.3) form of the name. On many file systems, a short file name contains a tilde character (~). However, not all file systems follow this convention. Therefore, do not make this assumption.

To get MS-DOS file names, long file names, or the full path of a file you can do the following:

To get an MS-DOS file name that has a long file name, use the GetShortPathName function.
To get the long file name that has a short name, use the GetLongPathName function.
To get the full path of a file, use the GetFullPathName function.

Windows stores the long file names on disk in Unicode. This means that the original long file name is always preserved, even if it contains extended characters, and regardless of the code page that is active during a disk read or write operation. The case of the file name is preserved, but the file system is not case-sensitive.

The valid character set for long file names is the NTFS file system character set less one character, which is the colon (":") that the NTFS file system uses to open alternate file streams. This means that you can copy files between the NTFS file system and FAT file system partitions without losing any file name information.

 
--------------------------------------------------------------------------------

 Last updated: March 2005  |  What did you think of this topic?  |  Order a Platform SDK CD
 © Microsoft Corporation. All rights reserved. Terms of use.


 
KSergey ©   (2009-02-13 09:31) [5]

> Германн ©   (13.02.09 01:20)  
> API-шные функции требуют, чтобы передаваемые им имена файлов
> были заключены в кавычки, если эти имена не укладываются в стандарт 8.3.

А можно пример?


 
clickmaker ©   (2009-02-13 13:31) [6]

> API-шные функции требуют, чтобы передаваемые им имена файлов
> были заключены в кавычки, если эти имена не укладываются
> в стандарт 8.3.

этого требуют функции, которые как-то разбирают переданную строку на части. Например, CommandLine в CreateProcess()
потому что без кавычек первый пробел будет трактоваться как окончание имени экзешника и начало его параметров командной строки.
если в имени файла нет таких разделителей, то будь оно сколь угодно длинным - кавычки не нужны.



Страницы: 1 вся ветка

Форум: "Прочее";
Текущий архив: 2009.04.12;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.005 c
2-1235026821
CodeMaster
2009-02-19 10:00
2009.04.12
C++ to Delphi


15-1234172735
pasha_golub
2009-02-09 12:45
2009.04.12
OpenSSL: ssl.h перевод для Delphi


15-1234330396
Василий Жогарев
2009-02-11 08:33
2009.04.12
Счетчики электрической энерии "Меркурий".


15-1234132776
Германн
2009-02-09 01:39
2009.04.12
Кодирование в mp3 аудио сигнала со входа микрофона.


15-1234336329
Германн
2009-02-11 10:12
2009.04.12
справочник по Си





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский