2 notes here:
1. I think NTFS streams is useless feature. I've never seen any
practical example of the usefulness of this.
2. I'm not sure there is any API to enumerate streams inside a given file.
--
Alexei Alexandrov
For my own purposes, I agree. However, some users and some applications will find uses for streams (same can be said of any feature). It would be much more useful if more filesystems supported it.
> 2. I'm not sure there is any API to enumerate streams inside a given file.
FindFirstStreamW()
FindNextStreamW()
Try setting the 'backupcopy' option to "yes".
I thought Vim did copy the streams, but I suppose this doesn't work when
you edit one specific stream. If you want to look at it: function
copy_infostreams() in src/os_win32.c
NTFS streams are mostly restricted to MS-Windows applications, and
rarely used. I don't think it's a good idea to support them in Vim
directly.
--
BEDEVERE: And what do you burn, apart from witches?
FOURTH VILLAGER: ... Wood?
BEDEVERE: So why do witches burn?
SECOND VILLAGER: (pianissimo) ... Because they're made of wood...?
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Just fooled around with this (I don't know much about NTFS streams ...).
Things to try out when writing the stream:
(1) simply add a bang:
:w!
(2) unset 'writebackup'
:h 'wb
:set nowb
:w
(3) set 'backupcopy' to "yes" (default is "auto")
:h 'bkc
:set wb bkc=yes
:w
...
To me, (3) looks ok, (2) and (1) less ok ...
I'd set these options only temporarily, when needed.
There must be some explicit support for streams, e.g. the swap file
is created as another stream.
--
Andy
On 31 Jan., 19:57, Alexei Alexandrov <alexei.alexand...@gmail.com>
wrote:
> 2 notes here:
> 1. I think NTFS streams is useless feature.
NTFS Streams can be used for the very same stuff resource streams on
MacOS or extended attributes on OS/2 / Linux are used. And in fact
> I've never seen any
> practical example of the usefulness of this.
You might want to get yourself the demo version of 4NT (http://
www.jpsoft.com/) and then use "DIR /:" a bit - you might be surprised
how many streams are already used on your system. Most notably:
12.12.2007 14:03 1'670 _H_A_________ .vimrc
0
{4c8cc155-6c1e-11d1-8e41-00c04fb9386d}:$DATA
I'm not aware well of Linux mechanisms for storing extended attributes
inside files on Linux. Word "Linux" looks strange to me here in fact -
it might a property of extX filesystem, but it doesn't have to do
anything with Linux I think since I may use other systems for root mount
point - reiserfs, for example. Do you have exact answers to the
following questions:
* Which mechanism is used on Linux to store these extended attributes on
Linux? Is it filesystem-based? If yes, which filesystems currently have
it implemented?
* Which applications use this feature on Linux? Are they OS-specific?
Are there application programs that use this? Are those programs
portable? If yes, how they deal with absence of this feature on other
file systems?
These are exactly questions which I would ask myself if I would be
designing something new and would be considering using NTFS file
streams. Will there be FAT32 file system clients? Would I care to port
the program to other system some time later? Et cetera. And most (if not
all) programs choose to use simple abstractions (files/directories)
available on all modern systems because it works well, because you'd
better keep it simple and because there are more important things to
focus on.
>
>> I've never seen any
>> practical example of the usefulness of this.
>
> You might want to get yourself the demo version of 4NT (http://
> www.jpsoft.com/) and then use "DIR /:" a bit - you might be surprised
> how many streams are already used on your system. Most notably:
>
> 12.12.2007 14:03 1'670 _H_A_________ .vimrc
> 0
> {4c8cc155-6c1e-11d1-8e41-00c04fb9386d}:$DATA
>
This looks like a default data stream in this file. I don't see that
there are 2 streams here - am I overlooking something?
P.S. I do see some cases where the data streams feature might be useful.
For example, anti-virus program might store some information about the
scanned file in a separate stream. But when I think of it more I realize
that even in these cases data streams approach would be questionable and
that there other ways to implement it with potentially better
performance and less limitations. For example, you cannot attach a new
data stream to a file which is available to you as read-only.
P.P.S. Thanks for reading to this point! :) Sorry for a long post and
somewhat clumsy English.
--
Alexei Alexandrov
While this would be nice, it would require support code from every
application you have. It may only be 6 lines, but 6 lines * 5000
binaries is much more code than is in vim for line ending detection.
After all, vim can't use this information unless something put it
there, which requires that everything that can create a file - from
touch to wget to shell redirection - needs to be able to put that
attribute into the file. And, AFAIK, there's no way for those wget or
shell redirection to even know what type of line ending the data that
they wrote out had. Which means they'd need to detect it. Which
would require that just about every program out there that is
transcribing a data stream from one spot to another, rather than
authoring it itself, would need to duplicate the sort of EOL detection
code in vim in itself. And vim would still need to continue
supporting the old way since it's designed to run on filesystems that
still don't support extended attributes - or it would need to come up
with a way to fake extended attributes on those FS types. No one is
saying that extended attributes can't do useful things - just that
without being in any way standardized, it's unreasonable to expect
that any attributes will ever be set by anyone but you.
That being said, if vim had a convenient way to see if extended
attributes support was available on the filesystem, it might be worth
caching things like the fileformat in the extended attributes, so it
only needed to be computed once... Though that might open up a whole
new can of worms, since someone could easily change the line endings
with another tool between two vim runs, confusing the n00b user with a
bunch of ^M's show up everywhere... all in all, this is one place
where manual detection seems the best idea.
For things like content encoding, it might be more useful - but again,
since every other tool doesn't create it, vim would still need to fall
back on autodetection if it couldn't find an attribute for it.
~Matt
I'm not sure that most other apps do need detection. wget, for
instance, doesn't have to care what line endings the data it saves
has. But, for what you want, it would have to detect and save it,
even though it doesn't use it. Shell redirection has no idea what's
going through it, so it has no way to possibly say what Content-type
it is... or dd... or tar extracting files that were created on a
filesystem that didn't track extended attributes...
> > After all, vim can't use this information unless something put it
> > there, which requires that everything that can create a file - from
> > touch to wget to shell redirection - needs to be able to put that
> > attribute into the file. And, AFAIK, there's no way for those wget or
> > shell redirection to even know what type of line ending the data that
> > they wrote out had. Which means they'd need to detect it.
>
> Just one example: The OS/2 version of ZIP would pack extended
> attributes. Once it catches on then more application will support it.
> But I know that this won't happen. We went down the "worse is better"
> way for far to long.
The issue isn't waiting for it to catch on, it's that until it's
universally available it only increases the amount of code and
maintenance burden. And, there's no way that it would ever be
universally available for things like line endings style, because most
applications just don't know or need to care, so have no reason to set
that attribute. Things like marking the content encoding might be
more useful, but still, not good to work with... If, for example, you
had a file "test.txt" encoded in UTF-16 and with extended attributes
marking it as such, and your locale is set to use UTF-8, what would
you expect the result of "cp test.txt test2.txt" to be? What about
"cat text.txt >text2.txt"? If you expect those two commands to have
the same effect, I don't see how it can be done without changes to cp
(mark attrs on dest), cat (mark attrs on stdout), and the kernel
itself (allow extended attributes on streams).
> > Which
> > would require that just about every program out there that is
> > transcribing a data stream from one spot to another, rather than
> > authoring it itself, would need to duplicate the sort of EOL detection
> > code in vim in itself. And vim would still need to continue
> > supporting the old way since it's designed to run on filesystems that
> > still don't support extended attributes - or it would need to come up
> > with a way to fake extended attributes on those FS types. No one is
> > saying that extended attributes can't do useful things - just that
> > without being in any way standardized, it's unreasonable to expect
> > that any attributes will ever be set by anyone but you.
>
> Ahh, indeed, there is the problem and the reason why computing has not
> advanced as much in the last 15 years as one would have expected
> seeing the 15 years before: Backward compatibilty has hobbled us.
The problem with this idea isn't the limitations inherent in backwards
compatibility - if it were worthwhile to do, it's no problem to have
code that uses attributes if possible and the old, backwards
compatible method if not. The problem is that creating this standard
and tying it properly into a POSIX OS would require a lot of low-level
changes. If we can agree on the requirements - that there must be
some number of predefined attributes that are set on every regular
file (and what about special files?), that the operating system must
handle initializing these attributes correctly when a file is created,
that streams would also need to have attributes, and that copying,
extracting, and in general "moving around" data will "just work", can
you see how difficult this would be to implement? To fully implement
this, the very least that's required is an operating system that only
supports filesystems that have some way of storing extended
attributes, a kernel that's able to initialize each of those
attributes on every file created, a shell that knows how to get/set
these attributes (and which it needs to set), and a copy of the
coreutils that are aware of the changes (so that "cp file1 file2"
creates file2 with the attrs of file1, not the defaults), at the very
least? And that work is just the baseline - the point where other
software can start counting on a base set of attributes that will
always exist, and trusting that they're correct. On a quick glance, I
see absolutely no way to do this properly without support from the OS.
~Matt
Indeed, I think it has. The Mac OS used to use resource forks and type attributes
which were beautiful. Now we have descended to the level of extensions and magic
numbers like everyone else. The filesystem supports resource forks and named
forks, but nobody's really using them yet--indeed, if anything, at the moment they
add confusion because some parts of the OS detect file types that way rather than
by extension, when available, so it's hard to know what's going on.
Ben.
Send instant messages to your online friends http://au.messenger.yahoo.com
And that sad story told, I do agree with the other posters who don't think this
has much use in Vim. I think to have some kind of consistency, probably an OS or
other fairly central component needs to lead the way, not a text editor.
Hmm... According to "info cp" (on my openSUSE 10.3 system), -a or --archive is
equivalent to -dpPR, which means:
-d copy symlinks as symlinks and preserve hardlinks between sources in the copies
-p preserve attributes. If not specifying which attributes, the default is:
mode,ownership,timestamps (xattrs must be specified explicitly to be included)
-P copy symlinks as symlinks (sic)
-R copy directories recursively
Best regards,
Tony.
--
"She said, `I know you ... you cannot sing'. I said, `That's nothing,
you should hear me play piano.'"
-- Morrisey
> Sad that everybody else only sees only hurdles and risks of change and
> not the chances and the risk of no-change.
>
> And yes: there is a rist of no-change!
I have to agree with krischik here. At University, I once got stuck in a
problem with some of the other mathematicians, who were all of the
opinion that "Yes, I'll have tea if you're having tea". Problem was,
nobody actually had tea. It took one of the lawyers to stand up and say
"Alright then, I'll have tea." Then all the mathmos jumped ship.
An amusing story perhaps, but it proves the point. In all things like
this, someone needs to jump first. Does it really matter who that is, as
long as someone does?
It's been a bone of contention of mine for years, the way modified keys
work in terminals. Five years ago XTerm gained ways to express generic
modified keys (e.g. Ctrl-Shift-Left). Only recently did any application,
such as Vim, start to understand those. It's always been a "you jump,
I'll jump" situation - why should the terminal send sequences nobody
would understand, or why should any application look for sequences nobody
would send? Someone has to go first.
Back to the subject of EAs - someone already has gone first. The GNU
fileutils already support EAs. As does tar. I also know that the lighttpd
webserver uses them by default, only falling back on filename-based
detection if the file doesn't have a "Content-Type" EA.
It'd be lovely if Vim could set those for it.
--
Paul "LeoNerd" Evans
leo...@leonerd.org.uk
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/
Oh, thanks - this is a good learning for me. It's a shame I never heard
of this before.
>
> On the other hand use of extended attributes could solve a problem
> with 5 lines of code where solving the same problem without could cost
> you 50. Determine file types, text file line endings and text file
> encoding come to my mind here. Ask Bram how many line of code he
> needed in Vim to determine these three informations. With consequent
> use of xattribs it would have been 6 lines:
>
> [...]
>
> And best of all: you know before you open the file. AFAIK Bram need to
> close and reopen files in unfortunate combinations.
>
Such attributes would be useful, yes. But it's backward compatibility
that is the root of all evil and you also mentioned this in a sibling
post. So I'm not sure these things will become popular unless there is a
brand new OS appears which doesn't have to be compatible with anything
and it wins the market.
Also, the named attributes story doesn't have to do much with numbered
NTFS data streams, does it? It might be similar but numbers are too far
from string identifier convenience. Which brings me back to my original
thought - the design and implementation of data streams in NTFS are useless.
--
Alexei Alexandrov
> On 1/31/08, Bram Moolenaar <Br...@moolenaar.net> wrote:
> >
> > Try setting the 'backupcopy' option to "yes".
>
> This worked, but then it raises another question. Previous value
> of the 'backupcopy' option was auto, which means yes or no, which
> works best. Why didn't it choose yes, if no fails?
Vim doesn't detect the situation that you are editing an info stream
directly.
> Also, in my configuration, backup option is no. Theoretically, I should
> not bother with all this stuff at all? I use Vim7.1 last official release.
The 'writebackup' option matters too.
> > I thought Vim did copy the streams, but I suppose this doesn't work when
> > you edit one specific stream. If you want to look at it: function
> > copy_infostreams() in src/os_win32.c
>
> This may take a while for me to set up everything...
>
> But i have an idea that the problem is with file names.
> When you open some specific stream, vim considers the stream name as
> filename, and filename as subfolder. The stream name is separated from file
> name with a colon (c:\path\foo.txt:bar), and the same colon is used to
> separate drive letter. Maybe this causes some confusion?
Detecting the colon should be simple. When not using NTFS the file name
would be illegal. I'll add a todo item for this. But it would be nice
if someone can make a patch for it.
> Also, VIM converts dots in file name to underscores sometimes, when
> streams are specified.
I haven't seen this. Perhaps it's because the long file name is
converted to a 8.3 file name? Can you give a reproducable example?
> > NTFS streams are mostly restricted to MS-Windows applications, and
> > rarely used. I don't think it's a good idea to support them in Vim
> > directly.
>
> I understand it, but vim has specific windows functionality anyway.
> But of course it is easy for me to suggest this and that :)
I always put more effort in functionality that works everywhere. And to
keep programs portable rare features should be avoided, especially when
they don't add something essential for the end user. MS thinks
otherwise: They want programs to only run on MS-Windows. Portability
means they might lose customers. Some Linux developers also go in this
direction, they don't care about MS-Windows users. I care for everybody
:-).
--
The process for understanding customers primarily involves sitting around with
other marketing people and talking about what you would to if you were dumb
enough to be a customer.
(Scott Adams - The Dilbert principle)
Oops, yep, I have a lot of stuff to catch up with.
--
Alexei Alexandrov